示例: clear all; clc; set(gca,'nextplot','replacechildren','box','off','color','b','xgrid','on'); title('Get 20 frames of current window'); %% for j=1:20
plot(fft(eye(j+16))); axis([-1. 1. -1. 1.]); frame(j)=getframe(gcf); % get the frame end writegif('test.gif',frame,0.1);
那么这个writegif函数如何写呢: function res=writegif(name,frames,dt) nframe = length(frames);
for i=1:nframe [image,map] = frame2im(frames(i)); [im,map2] = rgb2ind(image,128); if i==1 IMWRITE(im,map2,name,'GIF','WriteMode','overwrite','DelayTime',dt,'LoopCount',inf); else IMWRITE(im,map2,name,'WriteMode','append','DelayTime',dt); %,'LoopCount',inf); end end