video of plot iterations in MATLAB
9 views (last 30 days)
Show older comments
i am making a 3d plot using plot3 and i am also using quiver3 in it. i am running 100 iterations and pot keeps on updating. i am able to save the picture of the plot but how can i save or make video of the plot running iterations from matlab?
the picture after 100 iterations is as below:
0 Comments
Answers (1)
KSSV
on 11 Feb 2021
Edited: KSSV
on 11 Feb 2021
Proceed something like shown below:
h = figure;
axis tight manual % this ensures that getframe() returns a consistent size
filename = 'testAnimated.gif';
for n = 1:0.1:10
% Draw plot for y = x.^n
x = 0:0.01:1;
y = 0:0.01:1;
z = x.^n;
plot3(x,y,z)
drawnow
% Capture the plot as an image
frame = getframe(h);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
% Write to the GIF File
if n == 1
imwrite(imind,cm,filename,'gif', 'Loopcount',inf);
else
imwrite(imind,cm,filename,'gif','WriteMode','append');
end
end
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!