Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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

like image 360
Eka Avatar asked Aug 28 '12 10:08

Eka


1 Answers

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)
like image 182
Mercury Avatar answered Sep 23 '22 06:09

Mercury