how to skip from one line to another?

조회 수: 29 (최근 30일)
bsd
bsd 2012년 3월 21일
댓글: Travis Bemrose 2020년 3월 14일
Hai,
I have written a very long code, about 3000 lines, in matlab. For analysis purpose I need to go from line no. 240 to line no. 1401 directly. Is there any jump command to do this, apart from commenting (disabling) the other lines and also apart from using functions. For example in C program you have goto() command. Is there something similar to this in matlab? Looking forward for your reply.
BSD
  댓글 수: 1
Travis Bemrose
Travis Bemrose 2020년 3월 14일
Also looking for a solution. The only thing I'm aware of is highlighting the desired line and pressing F9, but this is sub-par because then you have to take over the function of the debugger by manually executing the rest of the lines.

댓글을 달려면 로그인하십시오.

답변 (4개)

Image Analyst
Image Analyst 2012년 3월 21일
What would be even nicer is if MATLAB had "edit and continue" like Visual Basic .Net does. You can set a breakpoint, then when it stops there, you can edit the code and start executing the new code without rerunning the program from the beginning, OR (what is really nice), you can grab the arrow and drag it to a new line that you want to start executing, for example you can skip past that "if" statement that you should step into but don't want to. Very very handy. People who use Microsoft Visual Studio love it.

Jan
Jan 2012년 3월 21일
No, there is no goto in Matlab and there are very good reasons not to implement it. Using functions is much more powerful and efficient.
  댓글 수: 1
Travis Bemrose
Travis Bemrose 2020년 3월 14일
You've missed the point. You're debugging/analyzing a function, and you need to skip over a line or two to see the rest of it run without executing the line the debugger is halted at and without commenting out those lines and saving the file which would stop the debugger.

댓글을 달려면 로그인하십시오.


Grzegorz Knor
Grzegorz Knor 2012년 3월 21일
I recommend to use if statement for this purpose:
x = 1:10;
y = x.^2;
if 0
y = sqrt(y);
end
plot(x,y)
See also:

Daniel Shub
Daniel Shub 2012년 3월 21일
But please do not. Just bite the bullet and spend a little bit of time learning how to write functions. It is going to make your life so much easier.

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by