Before MATLAB supported try
and catch
blocks, you could use eval
and evalc
with two arguments to obtain some of the same
functionality. In most cases, try/catch
blocks are much
faster.
Convert eval('foo', 'fclose(fid)')
to:
try
foo
catch ME
fclose(fid)
end
For more information and examples, see “The try-catch Statement”.