Hello everyone How could I get a video of the following animation?

Hello everyone How could I get a video of the following animation? The code is presented below the input vectors.. Any suggestion would be appreciated. Greetings.
figure()
t0001= [ -2 -1.9 -1.8 -1.7 -1.6 -1.5 -1.4 -1.3 -1.2 -1.1 -1 -0.9 -0.8 -0.7 -0.6 -0.5 -0.4 -0.3 -0.2 -0.1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2 ];
nc0001_1 = [ -0.99767992 -0.88465003 -0.50773837 0.02062628 0.54283833 0.90312743 0.99402317 0.78841229 0.34762635 -0.19685286 -0.68261294 -0.96475679 -0.95912388 -0.66739444 -0.1765883 0.36689228 0.80093276 0.99606345 0.89407894 0.52540013 0 -0.52540013 -0.89407894 -0.99606345 -0.80093276 -0.36689228 0.1765883 0.66739444 0.95912388 0.96475679 0.68261294 0.19685286 -0.34762635 -0.78841229 -0.99402317 -0.90312743 -0.54283833 -0.02062628 0.50773837 0.88465003 0.99767992 ];
n=length(t0001);
i=1;
while i<n
p=plot(t0001(1:i),nc0001_1(1:i));
set(gca,'FontSize',FS)
xtickformat("%.1f")
ytickformat("%.3f")
xlabel("Time, t(s)");
ylabel("Elevation free surface, n(m)");
leg=legend("Free surface",'Location','north','Orientation','horizontal');
leg.ItemTokenSize = [x1, x2];
legend('boxoff');
i=i+1;
xlim([2, 10]);
ylim([-0.025, 0.025]);
pause(0.01);
end

1 Kommentar

@Juan David Parra Quintero - I don't see calls to plot or equivalent in the above code so it is unclear what is being animated? As for creating a video, you may want to check Create AVI File from Animation for example code for creating a video.

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Pratheek
Pratheek am 11 Sep. 2023

0 Stimmen

I understand you want to get a video for an animation. One easy way to do this using Live Editor in Matlab.
Run your script in the Live Editor, after running your script you will get an option to export the animation (bottom left corner) in '.avi' format. I'm attaching a screenshot for your reference.
If you are using the same code to get the video, change the xlim accordingly.
Hope this helps you.
Image Analyst
Image Analyst am 11 Sep. 2023

0 Stimmen

Use writeVideo. See attached examples where I change a plot/graph/surface plot and make a movie out of the individual frames. It will be easy for you to adapt it to your equations.

Kategorien

Produkte

Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by