필터 지우기
필터 지우기

Plot function is blank

조회 수: 3 (최근 30일)
frozentangled
frozentangled 2020년 12월 1일
댓글: Ameer Hamza 2020년 12월 1일
Hey guys
I was working on displaying a function but my plot would just not display the graph I'd like to see
Here is the function I created
function yp=file(t,y)
a_1= -0.04;
a_2= -0.19;
a_3= 0.12;
b_1= 0.02;
b_2= -0.13;
b_3= 0.23;
c_1= 0.14;
c_2= 0.01;
c_3= 0.37;
d_1= -0.14;
d_2= -0.25;
d_3= -0.15;
yp = [(a_1 - b_1*y(1)- c_1*y(2)- d_1*y(3))*y(1);
(a_2 - b_2*y(1)- c_2*y(2)- d_2*y(3))*y(2);
(a_3- b_3*y(1)- c_3*y(2)- d_3*y(3))*y(3);
(a_1-2*b_1*y(1)-c_1*y(2)-d_1*y(3))*y(4)-c_1*y(1)*y(5)-d_1*y(1)*y(6);
-b_2*y(2)*y(4)+(a_2-b_2*y(1)-2*c_2*y(2)-d_2*y(3))*y(5)-d_2*y(2)*y(6);
-b_3*y(3)*y(4)-c_3*y(3)*y(5)+(a_3-b_3*y(1)-c_3*y(2)-2*d_3*y(3))*y(6)];
Here's the function I'd like to graph in
y0 = [0.31;0.20;0.49;0.00001;0.00001;0.00001];
t0 = 0;
tfinal = 100;
[t,y] = ode45(@file,[t0 tfinal],y0);
e=sqrt(y(:,4).^2+y(:,5).^2+y(:,6).^2);
e0=sqrt(0.00001^2+0.00001^2+0.00001^2);
f=abs(e/e0);
g=log(f);
a=1/t*g;
plot(t,a)
of course file referring to the above function yp
I don't think there are any erros in the code, but the plot just shows blank
Thank you in advance

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 12월 1일
Change the line
a=1/t*g;
to
a=1./t.*g;
  댓글 수: 2
frozentangled
frozentangled 2020년 12월 1일
Thanks! I'm really grateful!
Ameer Hamza
Ameer Hamza 2020년 12월 1일
I am glad to be of help!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Time Series Objects에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by