automatically save multiple graphs
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Sindar
le 9 Mar 2020
Modifié(e) : Sindar
le 9 Mar 2020
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
Réponses (0)
Voir également
Catégories
En savoir plus sur Graph and Network Algorithms dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!