HowTo 'IFError' and skip

조회 수: 34 (최근 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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by