MATLAB Answers

0

Breakpoints

Horia 님이 질문을 제출함. 2 Aug 2011
최근 활동 Walter Roberson 님이 편집함. 20 Feb 2018
Is there any method to set breakpoints to all the lines of a .m file, except manually one by one?

  댓글 수: 0

로그인 to comment.

답변 수: 4

Jan 님의 답변 2 Aug 2011

As Sean and Jiang I do not think that this is useful. But if you are sure that you need it:
i = 1;
while 1
try
dbstop(FuncName, sprintf('%d', i));
i = i + 1;
catch
break;
end
end

  댓글 수: 2

thanks, this answer really helped me.
Jan 22 Aug 2011
Is your problem solved?

로그인 to comment.


Sean de Wolski 님의 답변 2 Aug 2011

Why not just set one on the first line and step through it?
doc dbstop
doc dbstep

  댓글 수: 2

A tedious solution.
Moreover, it doesn't work inside loops for errors due to something else than the loop itself.
Sean de Wolski
on 2 Aug 2011
How does it work any differently than having a break point on that line?

로그인 to comment.


Fangjun Jiang 님의 답변 2 Aug 2011

Why do you need that? You can debug by running code line by line (pressing F10).

  댓글 수: 2

A tedious solution.
Moreover, it doesn't work inside loops for errors due to something else than the loop itself.
That doesn't make any sense. Typing F5 or F10 WILL work, even if you're stepping on a line that generates an error. How would an error get generated anyway, if not due to executing a statement in the loop that you are in? Doesn't make sense, unless you had some kind of parallel processing going and THAT process generated the error. Even that doesn't negate the fact that F5 and F10 will still work.

로그인 to comment.


Walter Roberson 님의 답변 2 Aug 2011

Yes, you can construct a script that would do this by issuing "dbstop" calls on your behalf. But like the others I do not see much point in it.

  댓글 수: 7

표시 이전 댓글 수: 4
As you (4) know,F12 (or a mouse click) selects only one line as a breakpoint.
Can all the lines of a .m file be selected at once?
Jan 2 Aug 2011
@Horia: Did my code what you want? If sets a break point in each line of the M-file, whose name is store in the variable FuncName. Does this differ from the requested behaviour, and if so, how?
If you were plotting a variable named values then
values(values<0) = nan;
MATLAB knows to skip plotting points with value nan.

로그인 to comment.



Translated by