Timer stops randomly in the middle of its callback

4 views (last 30 days)
I have a GUI with a timer. I start the timer, and it randomly will stop at some point while it is running and give the error: Index exceeds matrix dimensions. Error while evaluating TimerFcn for timer 'timer-1'
I do not think there is actually a matrix index it is accessing that is grater than the length of the index for a few reasons:
-All the matrices it accesses are much longer than the index it should be accessing at the time it stops
-The timer stops at different times every time I run it, which makes me feel like there is not a particular index limit that is actually causing problems
-I have commented out all the actual code the timer runs (so the timer literally just runs with no callbacks) and it still will stop at random times with the same error message.
I have no idea how to fix this. Is this just a buggy feature in matlab, or is there something else wrong with what I am doing.
I would also appreciate some help in figuring out how to better debug my code, as the error message does nothing to help me (it gives no line where the error occurs)
  3 Comments
per isakson
per isakson on 29 Sep 2017
The problem is that Matlab doesn't provide a "complete error message". (Caveat: as of R2016a at least)

Sign in to comment.

Answers (1)

Titus Edelhofer
Titus Edelhofer on 6 Aug 2017
Hi,
what did you write into your timer function, directly some code or the call of a MATLAB (.m) file? If you put your code into a .m file you should get proper error message with line numbers ...
Titus

Community Treasure Hunt

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

Start Hunting!