Effacer les filtres
Effacer les filtres

Plot function is blank

3 vues (au cours des 30 derniers jours)
frozentangled
frozentangled le 1 Déc 2020
Commenté : Ameer Hamza le 1 Déc 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

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Time Series Objects dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by