How can I get a cross-platform dbstop statement where a file separator is needed?

1 回表示 (過去 30 日間)
Josh G.
Josh G. 2021 年 9 月 21 日
コメント済み: Jan 2021 年 9 月 21 日
I need to insert a breakpoint into a class method at the beginning of a specific while loop. The position of this loop is subject to change over time, so I've put it in a function that I can reference. The class method is in its own file within a class folder that starts with '@'.
I can set the breakpoint on my Linux system with dbstop in @myClass/myFun>mainLoop, but this won't work on a Windows system where the command has to be dbstop in @myClass\myFun>mainLoop. I can reference a line number and get away without using the class prefix (e.g. dbstop in myFun.m at 30) but can't do the same with the function name (dbstop in myFun.m at mainLoop or dbstop in myFun at mainLoop).
I also tried putting this in an eval statement where the file separator was inserted into the command at run time, but eval interprets the file separator as an operator and gives me an error saying it's an invalid use of an operator.

採用された回答

Jan
Jan 2021 年 9 月 21 日
編集済み: Jan 2021 年 9 月 21 日
Do I understand correctly that you want to run
dbstop in @myClass/myFun>mainLoop
in Linux and under Windows:
dbstop in @myClass\myFun>mainLoop
? Then:
dbstop(fullfile('@myClass', 'myFun>mainLoop'))
% Or:
dbstop(['@myClass', filesep, 'myFun>mainLoop'])
  2 件のコメント
Josh G.
Josh G. 2021 年 9 月 21 日
Thanks, I'm not able to find this syntax anywhere in the documentation but it seems to work.
Jan
Jan 2021 年 9 月 21 日
See:
doc fullfile
doc filesep

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by