FUNCTION REFERENCE

assert

Throw an error when a condition is false.

Throw an error when a condition is false.

Syntax

assert(cond)

Syntax

assert(cond, msg, A1, ...)

Syntax

assert(cond, id, msg, A1, ...)

cond must be a logical or numeric scalar. When it is false, assert raises

"Assertion failed." or the message, formatted like error() with the extra

arguments; an identifier is kept for catch.

Example

x = 3; assert(x > 0, 'x must be positive')   % no output

Differences from MATLAB: none known.

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