Breakpoints

조회 수: 10 (최근 30일)
Horia
Horia 2011년 8월 2일
편집: Walter Roberson 2018년 2월 20일
Is there any method to set breakpoints to all the lines of a .m file, except manually one by one?

답변 (4개)

Jan
Jan 2011년 8월 2일
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
math07 rizqi
math07 rizqi 2011년 8월 22일
thanks, this answer really helped me.
Jan
Jan 2011년 8월 22일
Is your problem solved?

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


Sean de Wolski
Sean de Wolski 2011년 8월 2일
Why not just set one on the first line and step through it?
doc dbstop
doc dbstep
  댓글 수: 2
Horia
Horia 2011년 8월 2일
A tedious solution.
Moreover, it doesn't work inside loops for errors due to something else than the loop itself.
Sean de Wolski
Sean de Wolski 2011년 8월 2일
How does it work any differently than having a break point on that line?

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


Fangjun Jiang
Fangjun Jiang 2011년 8월 2일
Why do you need that? You can debug by running code line by line (pressing F10).
  댓글 수: 2
Horia
Horia 2011년 8월 2일
A tedious solution.
Moreover, it doesn't work inside loops for errors due to something else than the loop itself.
Image Analyst
Image Analyst 2011년 8월 2일
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.

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


Walter Roberson
Walter Roberson 2011년 8월 2일
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
Jan
Jan 2011년 8월 2일
@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?
Walter Roberson
Walter Roberson 2018년 2월 20일
편집: Walter Roberson 2018년 2월 20일
If you were plotting a variable named values then
values(values<0) = nan;
MATLAB knows to skip plotting points with value nan.

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

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by