How in Matlab R2019b fix error in ode45 solver command in solving a dynamic system consists of multiple ODEs equations?

1 次查看(过去 30 天)
I am sovling a system of 6 ODE functions, using ODE45 solver for RK4 method, i did as follows:
  1. i defined my function of ODEs in one file describing set of ODEs
  2. in another file i try to call this ODEs and solve it by ode45, here i inserted also model constants. initial values. etc.
but in matlab in command line of the ode45 sovler it keep returns error, though there were no any other error notification in other line.
3. Then i tryed to write both m files scripts into one m file conclude two function loops.
the result is same . always showing me error in ODE45 commend line in matlab, i need helpful resources. please have a look on my matlab scripts i uploaded. Thanks.

采纳的回答

darova
darova 2020-2-15
Mistakes
Also i suggest you to re-write your equations:
dxdt(1,1) = delH*N-(1-u1)*lamH*(x(6)/N)*x(1)-delH*x(1)+alfa*x(3);
dxdt(2,1) = (1-u1)*lamH*(x(6)/N)*x(1) -(delH+gamma+mu*u1)*x(2);
dxdt(3,1) = (gamma+mu*u1)*x(2)-(delH+alfa)*x(3);
dxdt(4,1) = ovip-(eta+epslL+delL)*x(4);
dxdt(5,1) = eta*x(4)-(1-u1)*lamV*(x(2)/N)*x(5)-(epslV*u2+delV)*x(5);
dxdt(6,1) = (1-u1)*lamV*(x(2)/N)*x(5)-(epslV*x(2)+delV)*x(4);
Because of:
[1 1;1 -1] % OK
[1 1;1-1] % ERROR DIMENSIONS
You can define constants outside the function:
Why don't you use variables?
% variables S_H=x(1);I_H=x(2);R_H=x(3);L_V=x(4);S_V=x(5);I_V=x(6);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by