take the execution to the specific line in matlab code

6 views (last 30 days)
I have some code in matlab, I want to take the execution from line 200 to line 100
I need something like gotoxy function in C
how can I do it in matlab?
thanks

Answers (2)

Azzi Abdelmalek
Azzi Abdelmalek on 8 Sep 2013
Edited: Azzi Abdelmalek on 8 Sep 2013
There is no goto instruction in Matlab. But you can avoid using it by using
while loop
if else if
break
continue
You can also call function

Walter Roberson
Walter Roberson on 8 Sep 2013
gotoxy is not part of the C standard. On systems and displays it is implemented on, it moves the display cursor to the indicated position, but it does not affect what is being executed. In C, the closest method to affect what is being executed is goto (which requires a named label as a target, not a line number.)
MATLAB does not have any mechanisms to continue execution at a specific line number or line label. There is no "goto" in MATLAB; there are only the regular control mechanisms such as "while" and "for" and "break" and "continue"
There might possibly be a mechanism for changing the position of the display cursor relative to the command window, but only for the case that the desktop interface of MATLAB is being used (not the command-line interface.) The mechanism is not a fundamental part of MATLAB, and if it exists it is somewhere down in the desktop object class that I have never explored. If this is what you are wanting to do and you are not trying to program the editor / command window interactions themselves, then you should consider instead presenting the text through a figure and using the supported interfaces for that.

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!