How to add two loops for two variables in a nonlinear ode

조회 수: 1 (최근 30일)
Long Cheng
Long Cheng 2016년 6월 23일
댓글: Long Cheng 2016년 6월 23일
For a nonlinear ode:
dy/dt=a*(1-10^(b*y))
How to solve this ode (i.e y) for different conditions, for example:
a=0:1:10 and b=0:1:10 at t=10?

답변 (2개)

Marc
Marc 2016년 6월 23일
See nested functions...
Basically you need to define a function that takes a and b as inputs, solves the ode with one of the ode solvers with the function nested. Anything outside the nested function, a and b are 'known' to the nested function.
function [yout, tout]= odeIn(a, b)
t = your time interval
Define your initial cond
yout = ode15s(yournestedfunc, t, initial cond)
function dydt = yournestedfunc(t)
your function with a and b
end
end
Something like that... Or you can turn your function into an anonymous function that calls a and b as variables. There is a good section in the help documentation on this...

Roger Stafford
Roger Stafford 2016년 6월 23일
This particular equation can be solved by ordinary calculus methods. It has the three possible analytic forms:
1) For y > 0, y = 1/(b*log(10))*log(1/(1-exp(-c*(t+K))))
2) y = 0, a constant in time
3) For y < 0, y = 1/(b*log(10))*log(1/(1+exp(-c*(t+K))))
where c = a*b*log(10) and where K is selected to satisfy whatever initial condition you apply to y.
You can derive these solutions by making the substitution
z = 10^(b*y)
and the resulting differential equation in z can readily be solved:
1/(z*(1-z))*dz/dt = a*b*log(10)
Evaluating the above expressions directly is presumably easier than making use of the numerical ‘ode’ functions in matlab (once you are convinced they are correct.)

카테고리

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