MATLAB Answers

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

6 views (last 30 days)
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 Comments

Mohammad Farhat
Mohammad Farhat on 7 Apr 2020
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.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 7 Apr 2020
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 Comments

Show 3 older comments
Mohammad Farhat
Mohammad Farhat on 8 Apr 2020
Thanks a lot for this explanation.
So this removed the nans (but still I dont have the needed results as in the figure..)
What do you think about using an event funtion for e ( x(1) ) so that it doesnt exceed 1? (this is a physical constraint )
Walter Roberson
Walter Roberson on 8 Apr 2020
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.

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Tags

Products


Release

R2018b