First of all, Matlab does have a movie feature. But is has several severe drawbacks: It stores all movie frames in memory, it has to be loaded before running (i.e., always runs one more time than you really desire), and it does not provide a `web-ready' format. These problems severely restrict the usefulness of Matlab's movie feature. (I checked this out thoroughly using Matlab 5, so I do not know whether anything improved in Matlab 6 (R12).)
What is the real reason to use movies in science and engineering? If the solution is three-dimensional and time-dependent in nature, then a movie is often the only sensible way to look at the entire sequence of results. In this case, it is not desirable and often impossible to store more data than necessary for one frame in memory.
The other common reason for making movies is that one wants to jazz up a presentation or a webpage. Therefore, it is important to be able to produce the final movie in some standard format that can be understood on the web.
Therefore finally, this note will present the solution in two steps: (1) First, Matlab is used as the graphing engine to produce each frame of the desired movie individually and save the result to a file. (2) Then, the Linux utility mpeg_encode is used to concatenate the individual movie frames into one mpeg-file.
This procedure satisfied my requirements. If you are interested in using a different package than Matlab, you just have to replace the first step.
The example drivermakemovie.m enclosed here creates the plot directly from a given formula. In practice, it is more likely that this will be again be split up into the two steps of reading result data from a file and creating the plot; that's what I use a code called makemovie.m for, which explains the name for drivermakemovie.m.
Basically, drivermakemovie runs through a time loop. For each time, a plot is created and printed to a ppm-file, which will from one movie frame. It is important to note how the filename is chosen: Its first part is the directory name ppmmovie, then a basename movie is used, then the loop counter n attached, and finally the extension chosen. The counter n is crucial and must be continuously counted integers, i.e., step size 1 in the loop on n is required. The basename movie is not crucial as such, but as the files will only be temporary, there is no reason to choose anything different.
A few additional, typically useful commands are used: The color limits are set to the same limits for each plot; only in this way will colors have the same meaning for different movie frames. Each plot is given a title that lets the viewer distinguish the frames later.
After running drivermakemovie, you should have the files movie0000.ppm, movie0001.ppm, ..., movie0016.ppm in the directory ppmmovie.
In the file paramfile, you only have to change very little, whenever you use it. The line ``INPUT movie*.ppm [0000-0016]'' specifies the name of the input files (the individual movie frames) to be movie*.ppm with the ``*'' replaced successively by 0000, 0001, ..., 0016. The range of numbers in this line is the only thing I ever change.
Finally, create the mpeg-movie by the Linux utility mpeg_encode using the information from paramfile by issuing the following command at the Linux prompt mpeg_encode paramfile This should create a file called movie.mpeg in the directory ppmmovie.
The line ``OUTPUT movie.mpeg'' in paramfile chooses the name of the output file. I never change this, but rather rename the file later to any desired name using the Unix command mv.
Remember to delete the ppm-files after creating the movie, because they are now useless and very large in real applications. Since those files were only used temporarily, I suggested to stick with the basename movie above.
To run a movie directly from a webpage, it might be necessary first to set the preferences in your browser to react properly to react to a mpeg-file in a href-link. Talk to your local web guru for more information on setting up a browser.