Creating AVI Movies from MATLAB images
Marcus Garvie

Here are a couple of examples of how to use MATLAB to make Audio Video Interleaved (AVI) movies on Linux. The resulting movies can be played independently of MATLAB. On Linux, for instance, there is the free XINE AVI movie player, and on a PC, there are Windows Media Player or QuickTime.

If you are happy just playing a movie within MATLAB then see

creating movies
in the MATLAB help pages. Note that a number of web-sites recommend using the free 'mpgwrite' software to convert a Matlab movie to an MPEG movie, but this doesn't appear to work with Linux anymore (the system crashes).

Here is an example of the animation of a simple series of sine wave graphs, each created with the plot command.

In the second example, the graphic image is "2D", a color contour plot of a 2D sine wave. The AVI movie takes much longer to create, and contains 51 frames:

Both these examples should be easily adapted to make other movies. For some reason in the 2D case replacing the plotting command 'pcolor' with 'surf' doesn't work very well. There's probably a simple remedy. Another problem is that AVI movie files can be very large. A solution to this problem is to compress the AVI files, which requires additional software (ask Computer Support).

Some brief notes regarding the use of the Linux movie player XINE are given here. After XINE has been installed on your machine (ask Computer Support) follow these steps after creating your AVI movie in Matlab:

  1. in a terminal window, type 'xine' (Enter);
  2. Right click mouse, then select open - file;
  3. Choose directory - filename, and the appropriate filter to show only AVI files;
  4. Click on the desired AVI file;
  5. Click on Select.

Once a file has been selected, it can be played quickly via

Right click mouse - Playback - Play
See the menu list for additional options (e.g. to control the speed at which the movie is played).

Last revised on 02 November 2004.