video of plot iterations in MATLAB
5 次查看(过去 30 天)
显示 更早的评论
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/516212/image.png)
0 个评论
回答(1 个)
KSSV
2021-2-11
编辑:KSSV
2021-2-11
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!