From: George Burdell on
I have a cell that results in a "??? Index exceeds matrix dimensions" error when I do "Evaluate Current Cell." The problem is that Matlab doesn't provide line numbers for errors in cells. Is this because I'm using an older version (R2007b)? What is the best way of finding the location of the error to correct it?

Adding a breakpoint somewhere in the cell or turning on "dbstop" doesn't help either, because breakpoints are ignored when evaluating individual cells.

If I want line numbers printed with the errors, I need to execute the whole m file, but I often have long m files and only want to repeatedly execute a single cell.

If a "goto" statement existed, I could simply add a goto line at the beginning of the m file so that it will jump to the cell, and then run the whole file, but of course we all know that a "goto" will probably never, ever be provided.

The best method I can think of is to CTRL-R (comment out) all the code above the cell temporarily and F5 (run) the whole script in order to get the line number, but this is several keystrokes of dumbness that I cannot put up with. It seems to defeat the whole purpose of cells, which is "rapid code iteration" that "makes the experimental phase of your work with MATLAB scripts easier" as written in the Matlab docs. If you can't debug individual cells, how can you do "rapid code iteration"?

Why can't Matlab just provide the error line numbers when evaluating cells? It would make life so much easier.

Any comments, suggestions?