|
MATLAB
num2str_d.m (MATLAB script)
Your software thinks that 1, 10, 11, 12, 2, 3, 4, ... is a proper filename order?
num2str_d(nomb, digits) converts integer numbers to strings like the inbuilt num2str, but it does this with a fixed number of digits.
num2str_d(1, 5) = 00001
How to make movies in Matlab?
Matlab has now reasonable functionalities to make AVI files through the commands avifile and getframe. However, for several reasons I prefer to make movies by first writing out a series of images and then assembling them into a movie. The main reason is that if you follow the instructions below you will obtain a movie that will work in PowerPoint presentations on all normal systems (no need to install DivX or so). Here is how I proceed:
1) Download the matlab script 'num2str_d.m' (see the link above) and put it in the same
directory as your matlab script.
2) put the lines
drawnow;
print('-dpng','-r80',['name_',num2str_d(it,5)]);
in the time / iteration loop after the plot in your matlab script.
'-dpng' : is the image format.
'-r80' : is the quality of the image (dpi). NOTE: Do not increase this too much.
Your aim must be to produce movies that don't have to be resized later to fit the resolution of your system / projector; this could lead to inproper interpolation and disappearance of lines and other fine structures in your movie.
Check the actual pixel resolution of the image files that result.
'name_' : is the filename.
'num2str_d(it,5)' : adds the number 'it' to the filename, with left hand zeroes added
such that the total number of digits becomes 5.
The reason to do this is to get the right numbering when you list
the files.
For example: growth_1, growth_10, growth_2, messes up the numbering while
growth_00001, growth_00002, ,growth_00010 will work fine.
NOTE: Don't produce too many frames. Usually 50 frames or so are fine to capture your model accuratly. It is enogh to play 2-4 frames a second, which leads to movies that are approx. 20 seconds. This gives you enough to comment on the development while the movie is playing and does not eat up too much of your airtime (12 minutes at normal conferences).
3) Start 'Gif Movie Gear' (this program is installed on PGP servers such as rock and on all new windows machines).
4) Click on 'Insert Frames' find your image files, mark them and the press 'open'.
5) The images will now be loaded (this can take some seconds) and a movie will be generated.
6) You can now edit and adjust the animation paramters. Especially interesting are Animation\Crop and Animation\Timing. Again, for the latter I suggest somthing like 30/100 of a second or so.
7) Choose 'save as' from the 'file'-menu. Remember to choose an appropriate movie format. Gif works well on the web and in PowerPoint, but does not allow for pausing. AVI with RLE8 compression works very well for PowerPoint and allows for pausing by clicking on the running movie.
Should you not have Gif Movie Gear then you can get a trial from www.moviegear.com. A problem that we often have with numerical models is that the time step size is adaptive and varies throughout the model. If you then produce a movie with a constant time interval between frames you distort the actual process evolution. To correct for this I got a special version of movie gear from the gamani people (1000 thanks for this!). This version has a special option Animation\Timing that allows to read in a text file that specifies the time between all frames individually. As long as the official releases don't have this option yet you can download the modified executable from here (just replace the official one in the program folder).
|