ode45 Error differential equation system

1 visualización (últimos 30 días)
gorilla3
gorilla3 el 13 de Oct. de 2017
Comentada: Torsten el 25 de Oct. de 2017
I'm trying to solve a system of differential equations with ode45 but an appears. Could someone help me spot the mistake(s)?
%%Parameters
R_la= 0.4;
R_sa_b= 5.03;
R_sv= 1.32;
R_lv= 0.56;
P_a_b= 100;
P_v= 6;
V_la=1;
V_sa_b= 12;
P_ic= 10;
Ca= 0.205;
k_ven= 0.186;
P_v1= -2.25;
V_vn= 28;
G_q= 3;
tau_q= 20;
Pa_co2_b= 40;
tau_co2= 40;
%%State parameters
F=@(t,V_sa,P1,P2) [ Ca.*(P1-P_ic);
((P_a_b-P1)./(R_la + 0.5 .*R_sa_b) - (P1-P2)./(0.5 .*R_sa_b+R_sv))./Ca;
((P1-P2)./(0.5 .*R_sa +R_sv)-(P2-P_v)./R_lv)./ (1./(k_ven.*(P2-P_ic-P_v1))) ]
[t,V_sa,P1,P2]= ode45(F,[0 10],[0 0 0]);
q= (P1-P2)./0.5 .*R_sa + R_sv ;
F1=@(t,xq,xc) [ (-xq+G_q .*(q-q_b)./q_b)./tau_q ;
(-xc +0.3+3.*tanh(Pa_co2./Pa_co2_b -1.1))./tau_co2 ]
[t,xq,xc]= ode45(F1,[0 10],[0 0 0]);
Error message:
Not enough input arguments.
Error in
CBF_v2>@(t,V_sa,P1,P2)[Ca.*(P1-P_ic);((P_a_b-P1)./(R_la+0.5.*R_sa_b)-(P1-P2)./(0.5.*R_sa_b+R_sv))./Ca;((P1-P2)./(0.5.*R_sa+R_sv)-(P2-P_v)./R_lv)./(1./(k_ven.*(P2-P_ic-P_v1)))]
Error in odearguments (line 87)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in CBF_v2 (line 37)
[t,V_sa,P1,P2]= ode45(F,[0 10],[0 0 0]);

Respuesta aceptada

Walter Roberson
Walter Roberson el 13 de Oct. de 2017
Change
F=@(t,V_sa,P1,P2) [ Ca.*(P1-P_ic);
((P_a_b-P1)./(R_la + 0.5 .*R_sa_b) - (P1-P2)./(0.5 .*R_sa_b+R_sv))./Ca;
((P1-P2)./(0.5 .*R_sa +R_sv)-(P2-P_v)./R_lv)./ (1./(k_ven.*(P2-P_ic-P_v1))) ]
[t,V_sa,P1,P2]= ode45(F,[0 10],[0 0 0]);
to
F = @(t, V_saP1P2) [ Ca.*(V_saP1P2(2)-P_ic);
((P_a_b-V_saP1P2(2))./(R_la + 0.5 .*R_sa_b) - (V_saP1P2(2)-V_saP1P2(3))./(0.5 .*R_sa_b+R_sv))./Ca;
((V_saP1P2(2)-V_saP1P2(3))./(0.5 .*R_sa +R_sv)-(V_saP1P2(3)-P_v)./R_lv)./ (1./(k_ven.*(V_saP1P2(3)-P_ic-P_v1))) ];
[t, V_saP1P2] = ode45(F, [0 10], [0 0 0]);
V_sa = V_saP1P2(:,1);
P1 = V_saP1P2(:,2);
P2 = V_saP1P2(:,3);
and similar changes for your F1
  8 comentarios
gorilla3
gorilla3 el 24 de Oct. de 2017
Hi Torsten,
in case you find my last comment confusing, here is a better overview: https://uk.mathworks.com/matlabcentral/answers/362979-ode-45-formulation-of-equations-in-system
Thanks again!
Torsten
Torsten el 25 de Oct. de 2017
Integrating your first equation from t'=0 to t'=t gives
V_sa(t)-V_sa(0)= Ca*(P1(t)-P_ic) - Ca*(P1(0)-P_ic)
This means that V_sa(t) can be expressed by P1(t) as
V_sa(t)=
V_sa(0)+ Ca*(P1(t)-P_ic) - Ca*(P1(0)-P_ic)=
V_sa(0)+Ca*(P1(t)-P1(0))
Consequently, you don't need to include a differential equation for V_sa in your system. The solution can be derived from the solution for P1 by the formula from above.
If you insist on solving a differential equation for V_sa:
d/dt(V_sa) = d/dt(Ca*(P1-P_ic)) = Ca*d/dt(P1)
Now for d/dt(P1), insert the expression from the right-hand side of the differential equation for P1.
Best wishes
Torsten.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by