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!