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

1 次查看(过去 30 天)
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