I\'m trying to find an error in my code. The error is in a function of 3rd level that initially works perfectly, but somehow at one point stops (the function is called many
Type
dbstop if error
then execute you code.
See doc of dbstop for more options.
Check to see if you are out of bounds of the array or other structure you are iterating over
Use dbstop if error. That dbstop command will take you to command prompt in the stopped function when the error occurs.
You can also get tricky and use the dbstop in FILESPEC at LINENO if EXPRESSION syntax. For example, if you want to break if the variable doesn't exist right before the line that trips the error, say line 224 of myFun.m:
dbstop in myFun.m at 224 if ~exist('x','var')
Then it will stop at line 224 of myFun.m if x is not a variable.