Matlab – How to make and save a video(avi) in matlab

MATLAB

I am learning matlab myself andI have made an animated plot using matlab;now i want to save it as an video file.can you tell me how to convert my animation into a video file in matlab.Below is my code

x=[1:2];
for i=1:25,
m=randi([3,5]);
n=randi([3,5]);
y=[m n];
bar(x,y)
axis equal                
A(i) = getframe;          
end

matlab version 7.8 R2009a

Best Answer

use avifile:

aviobj = avifile('example.avi','compression','None');
x=[1:2];
for i=1:25,
m=randi([3,5]);
n=randi([3,5]);
y=[m n];
bar(x,y)
axis equal        
aviobj = addframe(aviobj,gcf);       
drawnow 
end
viobj = close(aviobj)
Related Topic