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

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

回答(2 个)

Matt J
Matt J 2012-10-20
编辑:Matt J 2012-10-20
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 个评论

请先登录,再进行评论。


Matt J
Matt J 2012-10-20
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.

类别

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