Properties - MATLAB & Simulink (original) (raw)

Property declaration, attributes, and access methods

Properties contain object data. Classes define the same properties for all objects, but each object can have unique data values. Property attributes control what functions or methods can access the property. You can define functions that execute whenever you set or query property values. Properties can trigger events when code accesses their values.

Functions

expand all

properties Class property names
isprop Determine if property is defined by object

Numeric Value Attribute Validation

mustBePositive Validate that value is positive
mustBeNonpositive Validate that value is nonpositive
mustBeNonnegative Validate that value is nonnegative
mustBeNegative Validate that value is negative
mustBeFinite Validate that value is finite
mustBeNonNan Validate that input contains NaN
mustBeNonzero Validate that value is nonzero
mustBeNonsparse Validate that value is nonsparse
mustBeReal Validate that value is real
mustBeInteger Validate that value is integer
mustBeNonmissing Validate that input does not contain missing values (Since R2020b)

Comparison Validation

mustBeGreaterThan Validate that value is greater than another value
mustBeLessThan Validate that value is less than another value
mustBeGreaterThanOrEqual Validate that value is greater than or equal to another value
mustBeLessThanOrEqual Validate that value is less than or equal to another value

Member and Range Validation

mustBeMember Validate that value is member of specified set
mustBeBetween Validate that all elements are within specified range (Since R2025a)

Data Type Validation

mustBeA Validate that value comes from one of specified classes (Since R2020b)
mustBeNumeric Validate that value is numeric
mustBeNumericOrLogical Validate that value is numeric or logical
mustBeFloat Validate that value is floating-point array (Since R2020b)
mustBeText Validate that value is string array, character vector, or cell array of character vectors (Since R2020b)
mustBeTextScalar Validate that value is single piece of text (Since R2020b)
mustBeNonzeroLengthText Validate that value is text with nonzero length (Since R2020b)
mustBeUnderlyingType Validate that value has specified underlying type (Since R2020b)

Size Validation

mustBeNonempty Validate that value is nonempty
mustBeScalarOrEmpty Validate that value is scalar or empty (Since R2020b)
mustBeVector Validate that value is vector (Since R2020b)

Text with Special Meaning Validation

mustBeFile Validate that path refers to file (Since R2020b)
mustBeFolder Validate that input path refers to folder (Since R2020b)
mustBeValidVariableName Validate that input name is valid variable name (Since R2020b)

Classes

dynamicprops Superclass for classes that support dynamic properties
matlab.metadata.DynamicProperty Describe dynamic property of MATLAB object
event.DynamicPropertyEvent Event data for dynamic property events
matlab.metadata.Property Describe property of MATLAB class
matlab.metadata.Validation Describes property validation
matlab.metadata.FixedDimension Fixed dimension in property size specification
matlab.metadata.UnrestrictedDimension Unrestricted dimension in property size specification
matlab.metadata.ArrayDimension Size information for property validation
matlab.lang.OnOffSwitchState Represent on and off states with logical values

Topics

Define Properties and Set Attributes

Property Validation

Property Access Methods

Dynamic Properties