![]() The ValidateProps class defines three properties with validation.Ĭlass validation - This validation can cause conversion to a different The default constructor must return an object of the correct size. If you do not specify a default value, MATLAB creates a default value by assigning an empty object of the specified class or by calling the default constructor if size restriction does not allow the use of an empty default value. Specify Valid DefaultĮnsure that any default value assigned to the property meets the restrictions imposed by the specified validation. For more information, see Order of Validation. MATLAB evaluates the type specification before executing any validation functions. To ensure that a property can be assigned only a specific type of value, restrict the property to a type that supports only the desired type conversions or use a validation function to specify the exact class allowed for the property instead of specifying the property type. ![]() Therefore, restricting a property value to a specific numeric type, such as double does not prevent the assignment of other numeric types to the property. For example, MATLAB can coerce from one to another numeric type. MATLAB type conversion rules apply to property validation. For information on enumeration classes, see Define Enumeration Classes. If you want to restrict property values to a fixed set of identifiers, create an enumeration class for these identifiers and constrain the property to this class. Use property validation for public properties to control the values user code assigns to the properties. For more information, see Property Validation Functions.įor a list of MATLAB validation functions, see Property Validation Functions. Validator functions throw errors if the validation fails, but do not return values. MATLAB passes the value assigned to the property to each the validation functions after applying any possible class and size conversions. For more information, see Property Class Validation.įunctions - A comma-separated list of validation function names. Use any MATLAB class or externally defined class that is supported by MATLAB, except for Java ® and COM classes. The value assigned to the property must be of the specified class or convertible to the specified class. For more information, see Property Size Validation.Ĭlass - The name of a single MATLAB class. The value assigned to the property must conform to the specified size or be compatible with the specified size. A colon indicates that any length is allowed in that dimension. Size - The length of each dimension, specified as a positive integer or a colon.
0 Comments
Leave a Reply. |