Validate Property Values
In this section...
“Property Validation in Class Definitions” on page 8-24
“Sample Class Using Property Validation” on page 8-26
“Order of Validation” on page 8-27
“Abstract Property Validation” on page 8-28
“Objects Not Updated When Changing Validation” on page 8-28
“Validation During Load Operation” on page 8-28
Property Validation in Class Definitions
MATLAB property validation enables you to place specific restrictions on property values.
You can use validation to constrain the class and size of property values. Also, you can use
functions to establish criteria that the property value must conform to. MATLAB defines a
set of validation functions and you can write your own validation functions.
The use of property validation is optional in class definitions.
Validation Syntax
The highlighted area in the following code shows the syntax for property validation.
Property validations any of the of the following:
- Size — The length of each dimension, specified as a positive integer or a colon. A colon
indicates that any length is allowed in that dimension. The value assigned to the
8 Properties — Storing Class Data