dbstop inside an anonymous function

1 回表示 (過去 30 日間)
Leo Simon
Leo Simon 2013 年 2 月 10 日
Is there a way to set the debugger to stop inside an anonymous function?
The following obviously won't work
dbstop in myAnonFunction
because myAnonFunction is internal to my script. I can of course accomplish what I want with
dbstop if error
and then insert an error into my anonymous function. But this is hardly good practice! There must be a better way...
Thanks, Leo

回答 (2 件)

the cyclist
the cyclist 2013 年 2 月 10 日
編集済み: the cyclist 2013 年 2 月 10 日
As you may know, in the editor, inside a script you can click on the little hyphen next to the line number, and that will set a breakpoint.
If there is an anonymous function definition on that line of the script, you will be asked if you want the breakpoint at the beginning of that line of code, or at the anonymous function (i.e. whenever that function is called from elsewhere in the code).
EDIT in response to comment:
You can do this programmatically as follows:
>> dbstop in filename at 3@
will put a breakpoint at the anonymous function on line 3 of the file filename.m.
This is described in the section on "location" in
>> doc dbstop
  3 件のコメント
the cyclist
the cyclist 2013 年 2 月 10 日
Edited my response to explain how to do this programmatically.
per isakson
per isakson 2013 年 2 月 10 日
Thanks! Yes, it does but I missed it.

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


Leo Simon
Leo Simon 2013 年 2 月 10 日
Thanks, that's good to know. But I'm a dinosaur who hates GUIs so do everything from the command line. I use the -nodesktop flag and don't display the editor. Presumably there's a way to mimic that hyphen from the command line??
  1 件のコメント
the cyclist
the cyclist 2013 年 2 月 10 日
Leo, I edited my response to show how to do it programmatically.

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

カテゴリ

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