mustBeGreaterThanOrEqual
Checks that every element is greater than or equal to a bound.
Category: Programming > Functions
Syntax
mustBeGreaterThanOrEqual(A, c)
Checks that every element of A is greater than or equal to c. Returns nothing if the check passes and throws an error if not.
Description
mustBeGreaterThanOrEqual is a validator: it inspects its input and either returns silently or raises an error with the identifier MATLAB:validators:mustBeGreaterThanOrEqual. The error message states the requirement that was violated, so the caller sees what was expected rather than a generic failure.
Each element is compared with the scalar c using >=. Any element that fails the comparison makes the whole call error.
Input arguments
A- The value to check. Any array of the class the validator accepts.
c- Scalar bound to compare against.
Example
Passing and failing input
mustBeGreaterThanOrEqual([3 5 6], 3);
disp('passed')
try
mustBeGreaterThanOrEqual([1 5 2], 3)
catch err
disp(err.message)
end
Output
passed
Value must be greater than or equal to 3.
See also
mustBeGreaterThan mustBeLessThanOrEqual mustBeNonnegative mustBeInRange