MATLAB: Question on the use of ‘Return’

exceptional handling

What's the difference between
try
body
catch
return
end
and
try
body
end

Best Answer

try/catch followed by return has the effect of returning to the calling routine when an error is detected, without executing any following code. try with no catch, or try/catch that does not have a return (or exit or quit or error()) in the catch, continues executing after the try/end even if an error occurred.