How do I save a video with subplot?

13 次查看(过去 30 天)
Hi everyone!
I have a sequence of frames on which I have plotted two arrays in order to show the behaviour of a scenario using the subplot function. I used the videowriter function to save only the video, and so far I had no problems. Now I'd like to save a video with the two arrays displayed with subplot but it doesn' t seem to work. Is there some other function that I can use to show all my plots in the video? It seems that I may use the getframe function but so far i didn't understand how to deal with it. any other suggestions?

回答(1 个)

Prashant Arora
Prashant Arora 2017-3-8
Hi Andrea,
You can refer to the code below to get started on getframe and video writer.
h = figure;
subplot(2,1,2);
plot(1:10);
subplot(2,1,1);
plot(5:15);
F = getframe(h);
v = VideoWriter('myFile.avi');
open(v);
writeVideo(v,F.cdata)
close(v);

Community Treasure Hunt

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

Start Hunting!

Translated by