How to add two loops for two variables in a nonlinear ode
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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?
0 comentarios
Respuestas (2)
Marc
el 23 de Jun. de 2016
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
el 23 de Jun. de 2016
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.)
Ver también
Categorías
Más información sobre Ordinary Differential Equations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!