The idea is to create plot figures and compile them as frames of your movie.
% Create a new figure, and position it
fig1 = figure;
winsize = get(fig1,'Position');
winsize(1:2) = [0 0];
% Create movie file with required parameters
fps= 25;
outfile = sprintf('%s',outFileName)
mov = avifile(outfile,'fps',fps,'quality',100);
% Ensure each frame is of the same size
set(fig1,'NextPlot','replacechildren');
for i=1:numframes
plot(x,y); % generate your plot
% put this plot in a movieframe
% In case plot title and axes area are needed
% F = getframe(fig1,winsize);
% For clean plot without title and axes
F = getframe;
mov = addframe(mov,F);
end
% save movie
mov = close(mov);
Voila! (Make sure that you do not open any window over your plot window while MATLAB is compiling your movie, else those windows will become part of your movie)
Wednesday, December 22, 2004
Creating movies in MATLAB
If you want to show how your plots change with time, a movie is a good idea. Especially since MATLAB can produce movies that can be embedded in your presentations, or be seen with any good ol' movie player. Here's how:
Subscribe to:
Post Comments (Atom)
Moving to a new website
This website was intended to be a little collection of tips and tricks, but I haven't been able to update it as often as I originally in...
-
It is an easy matter to save data as a mat(MATLAB binary) file or an ASCII file so long as you know the filename beforehand. For ex: to save...
-
Over the course of my research and work I have accumulated a fair share of MATLAB hacks where I have used MATLAB to accomplish tasks that go...
-
If you want to format your data output as an XML file, here's how to do it without doing any complicated string handling. MATLAB can use...
6 comments:
avi.m does not seem to exist.
I'm getting the following error:
??? Failed to open file.
Error in ==> avifile.avifile at 163
aviobj.FileHandle = avi('open',filename);
Hi, me again.
I have found that it gives this error intermittently. When the error comes back, clearing any avi objects seems to help.
This is done by typing the followig in at the command window:
clear mex
I'm still not sure, however, why the error happens. Symptomatic of being a newb, I guess. ;)
Neat, clear walkthrough! Not too little and not too much, just perfect. Thank you :)
HI,
I am getting this error when i try to use the provided code.
??? Undefined function or variable 'outFileName'.
Kindly advice.
Ranitox
@ranitox
you should do it like this:
outfile = sprintf('%s','outFileName')
Hey guys do you know how we can adjust the movie to play in a specific axes size?
I mean i created a figure and provided it with the position property parameters. I have a structure holding the frames of a movie. Now i need to show this movie in the figure that i have created. But when i run it, the movie plays but its at a larger size than the figure size. I mean the movie frames dont scale down to the figure size.
Any suggestions on what i could do?
Post a Comment