can fsolve be used to generate values of an equation for different time steps?

1 visualización (últimos 30 días)
I want to know whether fsolve can be used to solve an equation of the form, X=somefunction of X. I want to get values of X at different time steps. For example consider the following equation,
X/(1-X)+(y1-y2)/90=1
y1 and y2 are to be calculated from ordinary differential equations. I am using ode45 to solve it.
Can the solver return a new value of X at every time step and use that in the next time step? If yes how can I solve it?
Thanks!

Respuestas (2)

Matt J
Matt J el 20 de Oct. de 2012
Editada: Matt J el 20 de Oct. de 2012
Yes, you can make a system of equations, (one equation for each time step) and have FSOLVE solve the total system.
However, it might be better to loop over the time steps and solve each equation separately instead. If X is expected to change smoothly with time, a loop will let you take advantage of that: you can initialize with the result of the previous time step
X(t) = fsolve(...,X(t-1))
helping the solver find the solution faster.
  3 comentarios
Urvi
Urvi el 20 de Oct. de 2012
I have 12 algebraic equations and 6 odes, all of which are inter related.
Matt J
Matt J el 20 de Oct. de 2012
Editada: Matt J el 20 de Oct. de 2012
Examples on the use of fsolve? That would be here.

Iniciar sesión para comentar.


Matt J
Matt J el 20 de Oct. de 2012
Note, the ability of FSOLVE to solve this could depend on y1,y2 and how they are related to X. Generally speaking, you need to be able to cast the problem in the form
F(X)=0
where F is a differentiable function. So, y1,y2 would probably have to be differentiable functions of X.

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!

Translated by