Ode45, evolution giving NaNs after some time, with no evidence of singularities in the equations

6 ビュー (過去 30 日間)
Hello,
Attached is a simple integrator for four coupled first order ode s.
after a certain time, the 4-vector solution turns into NaNs with no evidence of singularities in the equations.
This happens after a certain range where the solutions (starting as real) are written in complex notation although the imaginary part is zero. (why?)
can anyone please have a look and let me know if there's something im missing?
  2 件のコメント
darova
darova 2020 年 4 月 7 日
I tried to plot imiginary
plot(t1,imag(x(:,2)))
Result
Mohammad Farhat
Mohammad Farhat 2020 年 4 月 7 日
yes I said the notation at somepoint (if you check the entries of the solutions), for no apparent reason to me at least, becomes a complex notation, although as you've seen the solution is still purely real.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2020 年 4 月 7 日
Your first order, e1, gets to be more than 1.0, and then the sqrt(1-x^2) gets to be complex. Problems accumulate from there.
What are the original equations that you are trying to deal with? Do you have the Symbolic Toolbox ?
  6 件のコメント
darova
darova 2020 年 4 月 8 日
Thank you. This is something new
Walter Roberson
Walter Roberson 2020 年 4 月 8 日
I do not think an event function is appropriate here. Projection and failed steps is normal for ode45() .
Setting a MaxStep in the options might potentially help.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumeric Solvers についてさらに検索

タグ

製品


リリース

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by