How can you save an animated-line as a GIF file?

12 ビュー (過去 30 日間)
Roger Vegeta
Roger Vegeta 2020 年 10 月 22 日
コメント済み: Sindar 2020 年 10 月 24 日
How can I save the animation as a gif file for the following script?
(Omitting the PDSD function)
%initial concentrations
clear
clc
Nt = 1;
nodes = 11;
N = linspace(0,Nt,nodes);
Y0 = zeros(nodes,1);
% Y0 = [0.1;0.1;0;0;0;0;0;0;0;0;0];
%set integration
[tiempo,Yresult]=ode45(@PSDS, [0 8*3600], Y0);
[tn,~] = size(tiempo);
figure
for i = 1:tn
h(i) = animatedline('marker','o','LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor',[.49 1 .63],...
'MarkerSize',10);
end
for i = 1:tn
addpoints(h(i),N,Yresult(i,:))
title('PSDS Model')
xlabel('\eta (Dimensionless Volume)')
ylabel('\psi (Dimensionless Concentration)')
txt = ['Time = ',num2str(i*((8*3600)/tn)*(1/3600)),' hr'];
Ymax = max(Yresult(i,:));
T = text(0.1,Ymax,txt);
drawnow
pause(0.2)
if i ~= tn
delete(T)
else
% nothing
end
for k = 1:tn-1
clearpoints(h(k))
end
end
  3 件のコメント
Roger Vegeta
Roger Vegeta 2020 年 10 月 23 日
Thank you! However, the provided method only works for one "h". I have "i" number of figures.
Sindar
Sindar 2020 年 10 月 24 日
The provided method is for one figure handle h. You may have multiple line handles h, but that shouldn't matter. Just rename one of them

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeAnimation についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by