How can I calculate Y with the program(ODE45_main and ODE45_fun)?
27 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens

MATLAB program:
x y z b c is x(1——5), Y isn’t in the program
ODE45_fun【m.file】:
function dx=ODE45_fun(t,x)
dx = zeros(5,1); % a column vector
a1=1;a2=1;e1=9;e2=7;f1=56;f2=98;g1=76;g2=665;
a=a1+a2; e=e1+e2; f=f1+f2; g=g1+g2;
dx(1)=x(3)-x(2)+x(4)*x(2)-2*x(5)*x(2)-x(2)*x(2)-x(5)-e-f-g;
dx(2)=x(1)-x(3)+x(4)*x(2)-x(2)*x(2)-x(5)*x(5)-x(5)*x(2)-e*f-g;
dx(3)=x(2)-x(1)+x(5)*x(1)-x(4)*x(3)+x(3)+x(4)+e*g+f;
dx(4)=x(5)*a+x(3)*x(1)+x(3)+e*f*g*(x(4)*x(5)+x(2)*x(3)+e*f+e*g)
dx(5)=x(4)*a+x(2)*x(1)-e*f*x(1)-x(2)*x(2)*x(5)-x(2)*x(5)*x(5)-e*f-f*g
dx=[dx(1);dx(2);dx(3);dx(4);dx(5)]; %dx=[dx(1);dx(2);dx(3);dx(4);dx(5);dx(6)];
ODE45_main【m.file】:
tspan=[0,1e-5];
x0=[0;0.1;2;0;0.1];
[t,x]=ode45('ODE45_fun',tspan,x0);
data=[t,x];
save ODE45_data.txt data -ascii
subplot(2,3,1),plot(t,x(1))
subplot(2,3,2),plot(t,x(2))
subplot(2,3,3),plot(t,x(3))
subplot(2,3,4),plot(t,x(4))
subplot(2,3,5),plot(t,x(5))
%subplot(2,3,6),plot(t,x(6))
This program is in fact correct
【questions】 (1)Y=x(4)*x(5)+x(2)*x(3)+e*f+e*g
How can I calculate Y with the program(ODE45_main and ODE45_fun)?
(2)tspan=[0,1e-5];
How long it would take for calculation?
0 commentaires
Réponse acceptée
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!