I would put:
elseif all(max(v) <= vmax)
or
elseif max(v(:)) <= vmax
In MATLAB, if test
can pass even if test
is not a scalar. If test
is an array of logicals, it will pass if all the elements are non-zero.
However, that is not supported by MATLAB Coder when converting to C. So, you would need to explicitly ensure that you get a scalar, either by inserting an all
, or comparing v
to its maximum as a vector.