automatically save multiple graphs

2 次查看(过去 30 天)
hello,
The following code works fine when the value of omega is an integer. But, when the omega is not an integer the files are being saved as fig0.1.png.... how do I overcome this problem?
for omega = 0:0.1:1
xt=xo*cos(omegan*t)+((xodot)/(omegan))*sin(omegan*t)+ds*((cos(omega.*t)-cos(omegan*t))/(1-(omega/omegan)^2));
plot(t,xt);
title(['\omega/\omega_n = ' num2str(omega) '/1'])
fig=figure;
destination='X:\fakepath\R';
print([destination,num2str(omega),'.png']);
close(fig);
end
  2 个评论
Sindar
Sindar 2020-3-9
编辑:Sindar 2020-3-9
Matlab is doing exactly what you tell it to, naming files according to omega.
if you instead want to number files independent of omega (fig1.png,fig2.png,...):
omegas = 0:0.1:1;
for ind=1:length(omegas)
omega = omegas(ind); % or index in lines below)
xt=xo*cos(omegan*t)+((xodot)/(omegan))*sin(omegan*t)+ds*((cos(omega.*t)-cos(omegan*t))/(1-(omega/omegan)^2));
plot(t,xt);
title(['\omega/\omega_n = ' num2str(omega) '/1'])
fig=figure;
destination='X:\fakepath\R';
print([destination,num2str(ind),'.png']);
close(fig);
end

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graph and Network Algorithms 的更多信息

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by