i cant understand meaning of this comment . whenever i run program it show this msg. suggest any solution

1 view (last 30 days)
Maximum recursion limit of 500
reached. Use set(0,'RecursionLimit',N)
to change the limit. Be aware that
exceeding your available stack space
can
crash MATLAB and/or your computer.
Error in ==> ode45

Accepted Answer

James Tursa
James Tursa on 27 Jan 2013
Edited: James Tursa on 27 Jan 2013
You have a function that directly or indirectly calls itself. It did so 500 times without returning in your run. That usually means you have done this inadvertently in your code and you likely have a bug in your code (a forever recursion).
  1 Comment
Walter Roberson
Walter Roberson on 27 Jan 2013
Right.
It is common for beginners to attempt to use a structure such as
function myfun
... set up parameters
ode45('myfun', ....)
This kind of structure does not work, as it has myfun invoke ode45 which invokes myfun which invokes ode45, and so on endlessly.
Instead the following kind of structure should be used:
function myfun
... set up parameters
ode45(@myotherfun, ...)
end
function myotherfun(t,x)
... do what needs to be called from ode45
end

Sign in to comment.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!