Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

mustBeGreaterThanOrEqual

Validate that value is greater than or equal to another value or issue error

Syntax

mustBeGreaterThanOrEqual(A,B)

Description

example

mustBeGreaterThanOrEqual(A,B) issues an error if all elements in A are not greater than or equal to the scalar B. This function does not return a value.

mustBeGreaterThanOrEqual accepts user-defined objects if the class of the object implements these methods:

Examples

collapse all

Use mustBeGreaterThanOrEqual to validate that the values in the array are greater than or equal to 3.

mustBeGreaterThanOrEqual([2,3,4],3)
Error using mustBeGreaterThanOrEqual (line 19)
Value must be greater than or equal to 3.

Constrain property values to be greater than or equal to a specified value.

This class constrains the value of Prop1 to be greater than or equal to 3.

classdef MyClass
   properties
      Prop1 {mustBeGreaterThanOrEqual(Prop1,3)}
   end
end

Create an object and assign a value to its property.

obj = MyClass;
obj.Prop1 = 2;
Error setting property 'Prop1' of class 'MyClass':
Value must be greater than or equal to 3.

When you assign a value to the property, MATLAB® calls mustBeGreaterThanOrEqual with the value being assigned to the property. mustBeGreaterThanOrEqual issues an error because the value 2 is not greater than or equal to 3.

Input Arguments

collapse all

Value to validate, specified as a scalar or an array of one of the following:

Value that A must be greater than or equal to, specified as a scalar of one of the following:

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Introduced in R2017a

Was this topic helpful?