mustBeGreaterThan
Checks that every element is strictly greater than a bound.
Category: Programming > Functions
Syntax
mustBeGreaterThan(A, c)
Checks that every element of A is strictly greater than c. Returns nothing if the check passes and throws an error if not.
Description
mustBeGreaterThan is a validator: it inspects its input and either returns silently or raises an error with the identifier MATLAB:validators:mustBeGreaterThan. 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
mustBeGreaterThan([4 5 6], 3);
disp('passed')
try
mustBeGreaterThan([1 5 2], 3)
catch err
disp(err.message)
end
Output
passed
Value must be greater than 3.
See also
mustBeGreaterThanOrEqual mustBeLessThan mustBePositive mustBeInRange