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 comentarios

Sindar
Sindar el 9 de Mzo. de 2020
Editada: Sindar el 9 de Mzo. de 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
Lepakshi Ramkiran
Lepakshi Ramkiran el 10 de Mzo. de 2020
Yup....got it. Thanks

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre App Building en Centro de ayuda y File Exchange.

Productos

Versión

R2018a

Preguntada:

el 9 de Mzo. de 2020

Comentada:

el 10 de Mzo. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by