FUNCTION REFERENCE

if

Run statements only when a condition is true.

Run statements only when a condition is true.

Syntax

if condition, statements, end

Syntax

if condition, statements, else, statements, end

Syntax

if condition, statements, elseif condition, statements, else, statements, end

The condition is true when it is nonempty and all its elements are nonzero. Use && and || to combine scalar conditions. Write each statement block on its own lines in a script.

Example

x = 3; if x > 2, disp('big'), else, disp('small'), end   % prints: big

Differences from MATLAB: Not checked against MATLAB yet.

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