There are a few different ways to generate movies/videos/animations with MATLAB. Below is one method that works with Linux/Ubuntu.
There are two basic steps:
- In MATLAB, generate a sequence of images. Save those images as sequentially named files (ex, image-001.png, image-002.png, etc.).
- In Linux use a tool like ffmpeg or avconv to generate a movie file from the image sequence.
The code for these examples is at https://github.com/bsb808/matlabmovie
Step 1: Generating Image Sequence with MATLAB
Here is an example script that uses export_fig (described here) to generate a sequence of images in the "movie" directory.
Now you should have a bunch of image. The directory should look like this...
Step 2: Generating a Movie from Image Sequence
The following command should find these images and convert them to a movie with the file name out.mp4
The syntax is equivalent for ffmpeg. There are a bunch of cryptic options here.
If all goes well you should have the out.mp4 file as a movie...
Note the the video quality is not terribly high. To increase the quality you can adjust the image resolution in MATLAB and or the command line options for the avconv/ffmpeg call.