Breakpoints
2 次查看(过去 30 天)
显示 更早的评论
Is there any method to set breakpoints to all the lines of a .m file, except manually one by one?
0 个评论
回答(4 个)
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 个评论
Sean de Wolski
2011-8-2
Why not just set one on the first line and step through it?
doc dbstop
doc dbstep
2 个评论
Fangjun Jiang
2011-8-2
Why do you need that? You can debug by running code line by line (pressing F10).
2 个评论
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
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
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
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 Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!