Question: 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

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)

```
Have a look at [`VideoWriter`](https://uk.mathworks.com/help/matlab/ref/videowriter.html) or see this [`forum discussion`](https://uk.mathworks.com/matlabcentral/answers/455886-how-to-save-animated-plots#answer_370280)