필터 지우기
필터 지우기

Try-Catch clause fails in evalin

조회 수: 1 (최근 30일)
Ryan
Ryan 2017년 11월 29일
답변: Walter Roberson 2017년 11월 30일
Wondering if someone knows why try-catch syntax fail to work inside an evalin('caller',expression)? Are there any workarounds? Additionally, the following doesn't work, although I kind of expected it to.
try
evalin('caller',expression1);
catch E
evalin('caller',expression2);
end
My reason for even wanting to use these horrible statements (bad code practice) is to write a save function wrapper that by default picks faster compressionless saves unless it fails (usually for reasons of file size for compressionless save). And of course variables for the save() process are in the calling workspace.
  댓글 수: 2
Matt J
Matt J 2017년 11월 29일
What "failure" do you see? How does it manifest?
Ryan
Ryan 2017년 11월 30일
Ah, my bad. Should have included that. In essence it throws the error as if there's no catch statement.

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2017년 11월 30일
It does appear to generally work:
>> try; evalin('base','fooor'); catch ME; disp('caught'); end
caught
However, there are some errors that cannot be caught, including running out of memory and exceeding the recursion limit.

카테고리

Help CenterFile Exchange에서 Performance and Memory에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by