To perform the less-than or equal to
comparison in MATLAB you can use the <=
operator. It operates element-wise on arrays with the same size, and returns an array of logical 1 (true) where the relation is true and 0 (false) where it is not.
Example:
main.m48 chars4 lines
In this example, c
is the result of the element-wise comparison between arrays a
and b
. The result is:
main.m17 chars3 lines
since 1 <= 3, 3 <= 3, 5 is not <= 1, and 7 <= 7.
gistlibby LogSnag