System of ODEs with interdependent variables

조회 수: 24 (최근 30일)
Anna Jacobsen
Anna Jacobsen 2021년 2월 9일
댓글: Anna Jacobsen 2021년 2월 10일
I have to write a function that solves a differential equation which relies on three parameters. Each parameter is also described by a differential equation that calls the result of the first equation. I am unsure how to nest these as they all require each other as an input. I have initial values for each of them, but don't know where to go from there. I had listed all of the equations and called the ode45 function for each individually, which obviously didn't work as they rely on each other's outputs.
I've attached the equations below. The "main" ODE solves for V in terms of m, n, and h. Additionally, m, n, and h all vary with V based on unique exponential functions which I have already defined. All other variables are constants, I apologize for the clutter. How can I combine these?
dVdt = gna.*m^3.*h.*(Vna-V)+gk.*n^4.*(Vk-V)+gl.*(Vl-V)+I; %solve for V based on m, n, h
dndt = HH_an(V).*(1-n)-HH_bn(V).*n; %solve for n based on V
dhdt = HH_hm(V).*(1-h)-HH_bh(V).*h; %solve for h based on V
dmdt = HH_am(V).*(1-m)-HH_bm(V).*m; %solve for m based on V

채택된 답변

James Tursa
James Tursa 2021년 2월 9일
I would advise writing a derivative function for this. E.g.,
dydt = myderivative(t,y,gna,gk,gl,Vna,Vk,Vl,I)
V = y(1);
n = y(2);
h = y(3);
m = y(4);
dVdt = gna.*m^3.*h.*(Vna-V)+gk.*n^4.*(Vk-V)+gl.*(Vl-V)+I; %solve for V based on m, n, h
dndt = HH_an(V).*(1-n)-HH_bn(V).*n; %solve for n based on V
dhdt = HH_hm(V).*(1-h)-HH_bh(V).*h; %solve for h based on V
dmdt = HH_am(V).*(1-m)-HH_bm(V).*m; %solve for m based on V
dydt = [dVdt;dndt;dhdt;dmdt];
end
Then use your own solver or ode45( ).
  댓글 수: 5
James Tursa
James Tursa 2021년 2월 10일
What are all of the HH_etc( )? Are they functions?
Anna Jacobsen
Anna Jacobsen 2021년 2월 10일
Yes! Sorry for the lack of clarification. They are all functions in terms of V and each parameter (m, n, h) has an "alpha" and a "beta" function.
They all look like this, but with unique coefficients:
function ah = HH_ah(V)
ah = .07 * exp(-(V+65)/20);

댓글을 달려면 로그인하십시오.

추가 답변 (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