This archive contains routines that can be used to create an .avi animation on Windows computers from within MATLAB.
'getindexedframe.m' is used in a manner identical to that of MATLAB's 'getframe' function. It grabs an image from the current figure or from a user-specified figure or axis, and encodes the image using a color table. This saves memory compared to getframe's truecolor RGB format, but limits the maximum number of colors to 256.
After recording a vector of indexed images using getindexedframe, the movie can be written to an .avi-format Windows animation file using 'aviwrite.m'.
After downloading this archive in the directory of your choice, you may use 'sinewavemovie.m' to test the functionality of getindexedframe, aviwrite, and the dynamic-link library (.dll) files they call.
This routine has been tested under MATLAB 5.3, but it is known to return an error when called from MATLAB 5.2 and previous versions. Also, if aviwrite generates movies successfully but they come out garbled, try rightclicking on the Windows desktop and setting the Color Palette to any number of colors except 'True Color'. After generating your .avi movies, you can switch back to True Color and the files should still be viewable. (Thanks to Koljonen Emmi of the Tampere University of Technology in Finland for discovering this workaround.)
Michael Vick (2023). aviwrite (https://www.mathworks.com/matlabcentral/fileexchange/280-aviwrite), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!