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
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 Center 和 File Exchange 中查找有关 Graph and Network Algorithms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!