Jump command in MATLAB

Arash  picture Arash · Jul 4, 2009 · Viewed 87.9k times · Source

I'm working with the m-file editor of MATLAB and I need to jump from one line to another. If I need to jump from inside a For...end, I can't use the usual "while" technique.
Is there anyway to jump from a line to another, like goto in C?

Answer

gnovice picture gnovice · Jul 4, 2009

There is no goto statement in MATLAB, but there are a few other commands for use with loops that may help you:

  • continue: This statement will skip the remaining commands in a for or while loop and move on to the next iteration.
  • break: This statement will terminate execution of a for or while loop.