HowTo 'IFError' and skip

33 ビュー (過去 30 日間)
Scragmore
Scragmore 2011 年 12 月 2 日
How do identify an error in order that I can skip and run alternative script.
I want to
if fprintf('\t%s\n',TPin{1,2}{:}) iserror("??? Cell contents reference from a non-cell array object.")
do A;
else
do B;
90% of the time no error will occur, so would I be better writing;
do fprintf('\t%s\n',TPin{1,2}{:});
iserror goto do alternative;
In any case how do I pick up the error and perform a switch in task.

採用された回答

the cyclist
the cyclist 2011 年 12 月 2 日
You want to use a "try ... catch" construct:
>> doc try
  3 件のコメント
the cyclist
the cyclist 2011 年 12 月 2 日
Yes
Scragmore
Scragmore 2011 年 12 月 2 日
Thanks both of you, just what the doctor ordered.
AD

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by