operators-comparison

Programming

Comparison operators return 1 (true) or 0 (false). == tests equality, ~= tests inequality. < > <= >= test ordering. All work element-wise on arrays.

Syntax

a == b
a ~= b
a < b
a > b
a <= b
a >= b

Examples

5 == 5
▶ Run
3 ~= 4
▶ Run
[1, 2, 3] > 2  % returns [0, 0, 1]
▶ Run

See Also

Try SimLab — Free MATLAB® Alternative

466 functions. Runs in your browser. No install.

Open SimLab

Stay Updated

Get notified about new simulations and tools. We send 1-2 emails per month.