How to use fsolve solution as its initial values for the next step size
古いコメントを表示
Hi, I want to solve a system of nonlinear equations (having sine and cosine) inside a user-defined function in Simulink. It works well. However, the initial values I gave the solver for t=0 is no longer a good guess for the next step size of running the program. So my question is, how can I give the solver initial values equal to the solution for the previous step? Of course, at t=0, I have already set a vector of constant initial conditions. Note that if I connect the output of the block (solution of fsolve) as an input to the block (to be used as initial values for fsolve inside the block), there will be algebraic loop problem; consequently, the program stops. Any idea?
回答 (1 件)
Walter Roberson
2018 年 5 月 5 日
0 投票
Break the algebraic loop. See https://blogs.mathworks.com/simulink/2015/07/18/why-you-should-never-break-an-algebraic-loop-with-with-a-memory-block/
4 件のコメント
Ismaeel
2018 年 5 月 5 日
Walter Roberson
2018 年 5 月 5 日
As it is a user-defined function, presumably using a MATLAB Function Block, why not just use a persistent ?
Ismaeel
2018 年 5 月 5 日
Walter Roberson
2018 年 5 月 5 日
See for example the discussion at https://www.mathworks.com/matlabcentral/answers/309929-using-persistent-vars-in-custom-simulink-matlab-function
カテゴリ
ヘルプ センター および File Exchange で Modeling についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!