Can i record a figure as it is being plotted so that i can send it as an email attachment and viewed by someone who does not have matlab?

Réponses (1)

Hello. You can save an animated figure using VideoWriter() function. For example ,
writerObj = VideoWriter('example.avi');
writerObj.FrameRate = 60;
open(writerObj);
Z = peaks; surf(Z);
axis tight
set(gca,'nextplot','replacechildren');
set(gcf,'Renderer','zbuffer');
for k = 1:20
surf(sin(2*pi*k/20)*Z,Z)
frame = getframe;
writeVideo(writerObj,frame);
end
close(writerObj);
The animated plot is saved as an .avi file.

4 commentaires

Thanks. I manage to adapt it to my code. I get this error
Error using VideoWriter/writeVideo (line 383)
Frame must be 436 by 344
Error in videoooo (line 125)
writeVideo(writerObj,frame);
I can't really be much help unless I see your code. However, these links ( 1 and 2 ) might be useful for fixing your error.
When you use VideoWriter, every frame must be exactly the same size.
I am capturing the frames during plotting. In fact, I am having lots of for loop which are generating plots. Can I force the frames to be the same size for all the plots?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange

Question posée :

le 13 Juil 2015

Commenté :

le 15 Juil 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by