assert - Evaluate logical expression and stop simulation if false - MATLAB (original) (raw)

Main Content

Evaluate logical expression and stop simulation if false

Syntax

Description

assert(`expression`) evaluates a logicalexpression. Logical expressions evaluate to true or false. If the assert statement evaluates tofalse, simulation stops and returns an error.

example

assert(`expression`,`errmsg`) returns the specified error message string (errmsg) for the failedassert statement. If you run the test in the Test Manager, the error message appears in the simulation log. If you run the test outside the Test Manager, the message appears in the Diagnostic Viewer.

example

Examples

expand all

If either h or k are not 0, thisassert statement fails and simulation stops.

Tips

Version History

Introduced in R2015a