Error Handling

The error-handling statement—try/catch—is one of MATLAB’s four flow-control statements.

Basic syntax:

try
    try_block
catch
    catch_block
end

When this runs, MATLAB first attempts the try_block under try; if no error occurs, the program proceeds and the catch_block under catch is skipped. If an error is raised, control immediately transfers to the catch_block.