我可以在MatLab中为两个微分方程组使用两个单独的ODE调用函数吗?

我可以在MatLab中为两个微分方程组使用两个单独的ODE调用函数吗?,matlab,ode,Matlab,Ode,我试图编写一个ODE系统,如下所示 如图所示,第二个ODE完全取决于第一个ODE的值。 如何编写第二首颂歌? 我正在使用ode45。是的,这是很有可能的。将x定义为[c;ce],那么您就有了如下内容: function dx = my_ode(t,x) % parameters definition kf = ...; % whatever value you are using P0 = ...; % whatever value you are using Jer = ...; % w

我试图编写一个ODE系统,如下所示

如图所示,第二个ODE完全取决于第一个ODE的值。
如何编写第二首颂歌?
我正在使用ode45。

是的,这是很有可能的。将
x
定义为
[c;ce]
,那么您就有了如下内容:

function dx = my_ode(t,x)

% parameters definition
kf = ...; % whatever value you are using
P0 = ...; % whatever value you are using
Jer = ...; % whatever value you are using
J_serca = ...; % whatever value you are using
gamma = ...; % whatever value you are using

% differential equations
dc = (kf*P0+Jer)*(x(2)-x(1)) - J_serca;
dce = -gamma*dc;
dx = [dc;dce];
然后可以将ode解算器称为:

tspan = [0 10]; % or whatever time interval you want to solve the odes on
x_init = [0;0]; % ot whatever initial conditions you want to use
[T,Y] = ode45(@my_ode,tspan,x_init);

是的,很有可能。将
x
定义为
[c;ce]
,那么您就有了如下内容:

function dx = my_ode(t,x)

% parameters definition
kf = ...; % whatever value you are using
P0 = ...; % whatever value you are using
Jer = ...; % whatever value you are using
J_serca = ...; % whatever value you are using
gamma = ...; % whatever value you are using

% differential equations
dc = (kf*P0+Jer)*(x(2)-x(1)) - J_serca;
dce = -gamma*dc;
dx = [dc;dce];
然后可以将ode解算器称为:

tspan = [0 10]; % or whatever time interval you want to solve the odes on
x_init = [0;0]; % ot whatever initial conditions you want to use
[T,Y] = ode45(@my_ode,tspan,x_init);

是的,很有可能。将
x
定义为
[c;ce]
,那么您就有了如下内容:

function dx = my_ode(t,x)

% parameters definition
kf = ...; % whatever value you are using
P0 = ...; % whatever value you are using
Jer = ...; % whatever value you are using
J_serca = ...; % whatever value you are using
gamma = ...; % whatever value you are using

% differential equations
dc = (kf*P0+Jer)*(x(2)-x(1)) - J_serca;
dce = -gamma*dc;
dx = [dc;dce];
然后可以将ode解算器称为:

tspan = [0 10]; % or whatever time interval you want to solve the odes on
x_init = [0;0]; % ot whatever initial conditions you want to use
[T,Y] = ode45(@my_ode,tspan,x_init);

是的,很有可能。将
x
定义为
[c;ce]
,那么您就有了如下内容:

function dx = my_ode(t,x)

% parameters definition
kf = ...; % whatever value you are using
P0 = ...; % whatever value you are using
Jer = ...; % whatever value you are using
J_serca = ...; % whatever value you are using
gamma = ...; % whatever value you are using

% differential equations
dc = (kf*P0+Jer)*(x(2)-x(1)) - J_serca;
dce = -gamma*dc;
dx = [dc;dce];
然后可以将ode解算器称为:

tspan = [0 10]; % or whatever time interval you want to solve the odes on
x_init = [0;0]; % ot whatever initial conditions you want to use
[T,Y] = ode45(@my_ode,tspan,x_init);

不应该
dce=-gamma*dc取x(1)而不是dc,因为dc不是ode的值@am304No
x(1)
c
,而不是
dc/dt
。您需要
dc
,它在前一行中定义,因此它是有效的。哦,好的。“Y”存储的是dc和dce的值吗?不。
Y
(我真的应该叫它
X
)存储的是
c
ce
的值:
Y=[c;ce]。我认为您解决了实际问题,但要回答OP的标题问题:不,在这种情况下,您不能“对两个微分方程的系统使用两个单独的ODE调用函数”,因为方程没有完全解耦。这实际上是一个二阶系统。方程必须同时积分。不应
dce=-gamma*dc取x(1)而不是dc,因为dc不是ode的值@am304No
x(1)
c
,而不是
dc/dt
。您需要
dc
,它在前一行中定义,因此它是有效的。哦,好的。“Y”存储的是dc和dce的值吗?不。
Y
(我真的应该叫它
X
)存储的是
c
ce
的值:
Y=[c;ce]。我认为您解决了实际问题,但要回答OP的标题问题:不,在这种情况下,您不能“对两个微分方程的系统使用两个单独的ODE调用函数”,因为方程没有完全解耦。这实际上是一个二阶系统。方程必须同时积分。不应
dce=-gamma*dc取x(1)而不是dc,因为dc不是ode的值@am304No
x(1)
c
,而不是
dc/dt
。您需要
dc
,它在前一行中定义,因此它是有效的。哦,好的。“Y”存储的是dc和dce的值吗?不。
Y
(我真的应该叫它
X
)存储的是
c
ce
的值:
Y=[c;ce]。我认为您解决了实际问题,但要回答OP的标题问题:不,在这种情况下,您不能“对两个微分方程的系统使用两个单独的ODE调用函数”,因为方程没有完全解耦。这实际上是一个二阶系统。方程必须同时积分。不应
dce=-gamma*dc取x(1)而不是dc,因为dc不是ode的值@am304No
x(1)
c
,而不是
dc/dt
。您需要
dc
,它在前一行中定义,因此它是有效的。哦,好的。“Y”存储的是dc和dce的值吗?不。
Y
(我真的应该叫它
X
)存储的是
c
ce
的值:
Y=[c;ce]。我认为您解决了实际问题,但要回答OP的标题问题:不,在这种情况下,您不能“对两个微分方程的系统使用两个单独的ODE调用函数”,因为方程没有完全解耦。这实际上是一个二阶系统。这些方程必须同时积分。