FUNCTION REFERENCE

try

Run statements with optional error handling.

Run statements with optional error handling.

Syntax

try; statements; catch err; handler; end

Syntax

try; statements; catch; handler; end

Syntax

try; statements; end

On success, skips the catch block. A catchable runtime error skips the remaining try statements and runs the handler. Without a catch block, a catchable error is suppressed. Blocks may be nested; assignments completed before an error remain available. Parse errors are rejected before execution.

Example

try; error('stop'); catch; disp('caught'); end   % caught

Differences from MATLAB: The catch value is a struct with an empty stack. Cancellation and execution limits cannot be caught.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.