Making Movies in Matlab


Here is brief tutorial on making movies in Matlab (on Microsoft Windows).
In order to make them on Linux, we have to download the program gifmerge.tar.gz from the-labs.com Download it to a directory on calclab1.math.tamu.edu, then execute the following commands (where % is your prompt)
% gunzip gifmerge.tar.gz
% tar xvf gifmerge.tar
% make
After executing these commands, you should have a working binary executable called gifmerge.

You can check that it works by typing
% ./gifmerge -h
in the directory where it exists.


The main steps in our approach to making movies in Matlab is
  1. use matlab commands to make a series of frames and capture them with the "print" command to a set of PostScript files. They must be named in the order they will appear. Example (in Matlab command window):
    >> for i=1:10 
    x = linspace(0,10,101); 
    plot(x,sin(x+i)); 
    print(gcf,'-deps',strcat('plot',num2str(i),'.ps')); 
    end
    
  2. The PostScript files are then converted to GIF files (transparent or not). Example (in Linux terminal window)
    % foreach i (*.ps)
    pstogif $i
    end
    
  3. A program is then run to merge the gif files into an animated GIF.
    ./gifmerge plot?.gif plot??.gif > anim.gif
    
  4. You can copy the file gifmerge and ps2togif from my directory to yours by executing the following commands
    cp ~mpilant/public_html/gifmerge .
    cp ~mpilant/public_html/pstogif .
    
The advantage of animated GIF's is that they are very small, quick to load, and very portable. The disadvantage is they do not have sound.

Matlab has several built in commands to make AVI files, but they intermediate files are so large, most students exceed their disk quotas trying to make them...


Other Links: