for i = 1:100
h = figure(1);
% 下面一行替换为想要显示的内容
imshow([num2str(i),'.jpg']);
frame = getframe(h);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
% Write to the GIF File
if i == 1imwrite(imind,cm,[num2str(i),'.gif'],'gif', 'Loopcount',inf,'DelayTime',0.01);
else
imwrite(imind,cm,[num2str(i),'.gif'],'gif','WriteMode','append','DelayTime',0.01);
end
end