HowTo 'IFError' and skip

44 次查看(过去 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 个评论
Scragmore
Scragmore 2011-12-2
Thanks both of you, just what the doctor ordered.
AD

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by