フィルターのクリア

Running for loop designated number of times in debugger

41 ビュー (過去 30 日間)
Mark
Mark 2013 年 11 月 27 日
コメント済み: Walter Roberson 2017 年 10 月 4 日
Hi,
An error occurs in a for loop in my code on the 2nd to last iteration (>1500 runs) and I want to step into some functions in the loop during that iteration but don't want to manually step 1500+ times to get there. Any suggestions?
Thanks,
Mark

回答 (2 件)

Steven Lord
Steven Lord 2017 年 10 月 4 日
Instead of setting a regular breakpoint, set either an error breakpoint or a conditional breakpoint whose condition includes the loop variable. See the documentation for instructions on how to set either of those types of breakpoint. In fact the example for conditional breakpoints on that page does exactly what you want to do, breaking on certain iterations of a for loop.
  1 件のコメント
Walter Roberson
Walter Roberson 2017 年 10 月 4 日
For example,
dbstop at 173 if i == length(A)-1

サインインしてコメントする。


Juan Heredia
Juan Heredia 2017 年 10 月 4 日
Hey
What I've been doing so far is putting a breakpoint where "x=1" the manually stepping through the next few steps.
if i == 1499
x=1;
end
Stumbled across this while looking for a cleaner solution, though.
Best of luck

カテゴリ

Help Center および File ExchangeDebugging and Analysis についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by