フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Role of breakpoints in MATLAB

3 ビュー (過去 30 日間)
Swati Sarangi
Swati Sarangi 2020 年 11 月 11 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hi All,
I just want to know about the role of break points ( that red coloured dot which we put while clicking on the line number). Why is that put in a program?
Thanks in advance
Regards
Swati
  1 件のコメント
Stephen23
Stephen23 2020 年 11 月 11 日
編集済み: Stephen23 2020 年 11 月 11 日
"I just want to know about the role of break points"
They stop code execution when the execution reaches that particular point in the code, and allows you to view the variable values at that point, execute commands, etc., which helps with debugging.
"Why is that put in a program?"
Strictly speaking it is not "put in a program" as it is a feature entirely provided by the IDE and is not saved or stored in any way in the Mfile program text itself.

回答 (1 件)

Rik
Rik 2020 年 11 月 11 日
They are used for debugging. You can also set a conditional breakpoint (right-click on the dash).
With a breakpoint you can pause execution of your code at a specific point so you can verify your variables are what you expected.
  2 件のコメント
Ameer Hamza
Ameer Hamza 2020 年 11 月 11 日
Another useful conditional breakpoint is based on error using dbstop(): https://www.mathworks.com/help/matlab/ref/dbstop.html#buyrwwr-condition
Rik
Rik 2020 年 11 月 11 日
I sometimes use this during debugging (although I sometimes use 1+1; instead of the warning). This code sets a breakpoint on the second line.
a=dbstack;dbstop('in',strrep(mfilename,'.m',''),'at',num2str(a(1).line+1)),drawnow
warning('bad things are happening here')
This allows me to leave the 'pause on errors' off and focus on a single point of failure. It also keeps working in the fringes: Maltab 6.5 and Octave can both handle this, and it keeps working, even if you have a clear all to simulate a fresh start of Matlab.

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by