Awesome movie in Matlab (makes gif)

For making beautiful gifs in Matlab, like the ones showed on this website you should stay clear of matlab built-in functions. I found Matlab to excel at making eps files, therefore I use it to do so. Then with system commands, I convert the eps file into a png file. For higher quality, the convert -density parameter should be increased. Once all frames are created, another system command converts the png files to a gif animation. This code expects a folder named “frames” at the same location as the Matlab code. Then play with the convert -delay parameter to change the frame rate. Convert command is available on Linux platforms.

for frame=1:50
ax=axes(); hold on;
set(ax,'xlim',[1 100],'ylim',[1 100])
print(gcf, '-depsc2','-loose',[filename,'.eps']);
system(['cd  frames;','convert -density 170x170 frame',num2str(f,'%0.3i'),'.eps frame',num2str(frame,'%0.3i'),'.png'])
system(['cd  frames; convert -delay 5 -loop 0 *.png anim.gif'])

Leave a Reply

Your email address will not be published. Required fields are marked *