Plot function is blank

1 Ansicht (letzte 30 Tage)
frozentangled
frozentangled am 1 Dez. 2020
Kommentiert: Ameer Hamza am 1 Dez. 2020
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

Akzeptierte Antwort

Ameer Hamza
Ameer Hamza am 1 Dez. 2020
Change the line
a=1/t*g;
to
a=1./t.*g;
  2 Kommentare
frozentangled
frozentangled am 1 Dez. 2020
Thanks! I'm really grateful!
Ameer Hamza
Ameer Hamza am 1 Dez. 2020
I am glad to be of help!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by