catch
catch is used in try-catch blocks and is executed when an exception or error occurs in the try block.
Syntax
catch (errorhandler)
Inputs
- errorhandler
- Code to be executed when an error occurs in the try block.
Example
try
a*2
catch
disp('Error in try block, cannot find variable [a]');
end
Error in try block, cannot find variable [a]