# Error while saving multiple graphs.

조회 수: 1(최근 30일)
Lepakshi Ramkiran 2020년 3월 9일
댓글: Lepakshi Ramkiran 2020년 3월 9일
for omega = 0:0.01:0.99999
xt=xo*cos(omegan*t)+((xodot)/(omegan))*sin(omegan*t)+ds*((cos(omega*t)-cos(omegan*t))/(1-(omega/omegan)^2));
t=plot(t,xt);
title(['\omega/\omega_n = ' num2str(omega) '/1'])
saveas(gcf,num2str(omega),'jpg')
end
Undefined operator '*' for input arguments of type 'matlab.graphics.chart.primitive.Line'.
Error in forced (line 13)
xt=xo*cos(omegan*t)+((xodot)/(omegan))*sin(omegan*t)+ds*((cos(omega*t)-cos(omegan*t))/(1-(omega/omegan)^2));
The above error is being displayed while executing the above code. What is that error? how to rectify it?
The code is working fine when not in a loop.

댓글을 달려면 로그인하십시오.

### 채택된 답변

Ameer Hamza 2020년 3월 9일
편집: Ameer Hamza 2020년 3월 9일
You are using variable t as both numeric and graphics objects. Correct the second line of for loop
for omega = 0:0.01:0.99999
xt=xo*cos(omegan*t)+((xodot)/(omegan))*sin(omegan*t)+ds*((cos(omega*t)-cos(omegan*t))/(1-(omega/omegan)^2));
T=plot(t,xt);
title(['\omega/\omega_n = ' num2str(omega) '/1'])
saveas(gcf,num2str(omega),'jpg')
end
##### 댓글 수: 1표시숨기기 없음
Lepakshi Ramkiran 2020년 3월 9일
Yup!! Got it... Thanks.

댓글을 달려면 로그인하십시오.

### 범주

Find more on Migrate GUIDE Apps in Help Center and File Exchange

R2018a

### Community Treasure Hunt

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

Start Hunting!

Translated by