Main Content

Properties

Property declaration, attributes, and access methods

Properties contain object data. Classes define the same properties for all object, 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.

Funktionen

alle erweitern

propertiesClass property names
ispropTrue if property exists

Numeric Value Attribute Validation

mustBePositiveValidate that value is positive
mustBeNonpositiveValidate that value is nonpositive
mustBeNonnegativeValidate that value is nonnegative
mustBeNegativeValidate that value is negative
mustBeFiniteValidate that value is finite
mustBeNonNanValidate that value is not NaN
mustBeNonzeroValidate that value is nonzero
mustBeNonsparseValidate that value is nonsparse
mustBeRealValidate that value is real
mustBeIntegerValidate that value is integer
mustBeNonmissingValidate that value is not missing

Comparison Validation

mustBeGreaterThanValidate that value is greater than another value
mustBeLessThanValidate that value is less than another value
mustBeGreaterThanOrEqualValidate that value is greater than or equal to another value
mustBeLessThanOrEqualValidate that value is less than or equal to another value

Data Type Validation

mustBeAValidate that value comes from one of specified classes
mustBeNumericValidate that value is numeric
mustBeNumericOrLogicalValidate that value is numeric or logical
mustBeFloatValidate that value is floating-point array
mustBeTextValidate that value is string array, character vector, or cell array of character vectors
mustBeTextScalarValidate that value is single piece of text
mustBeNonzeroLengthTextValidate that value is text with nonzero length
mustBeUnderlyingTypeValidate that value has specified underlying type

Size Validation

mustBeNonemptyValidate that value is nonempty
mustBeScalarOrEmptyValidate that value is scalar or empty
mustBeVectorValidate that value is vector

Member and Range Validation

mustBeMemberValidate that value is member of specified set
mustBeInRangeValidate that value is in the specified range

Text with Special Meaning Validation

mustBeFileValidate that path refers to file
mustBeFolderValidate that input path refers to folder
mustBeValidVariableNameValidate that input name is valid variable name

Klassen

dynamicpropsSuperclass for classes that support dynamic properties
meta.DynamicPropertyDescribe dynamic property of MATLAB object
event.DynamicPropertyEventEvent data for dynamic property events
meta.propertyDescribe property of MATLAB class
meta.Validation Describes property validation
meta.FixedDimension Fixed dimension in property size specification
meta.UnrestrictedDimension Unrestricted dimension in property size specification
meta.ArrayDimension Size information for property validation
matlab.lang.OnOffSwitchStateRepresent on and off states with logical values

Themen

Define Properties and Set Attributes

Property Validation

Property Access Methods

  • Property Access Methods
    Property access methods execute code when property values are referenced or assigned. Implementing these methods enables you to control what actions occur when values are set or queried.
  • Property Set Methods
    Property set methods must follow specific syntax and execution rules.
  • Property Get Methods
    Property get methods must follow specific syntax and execution rules.
  • Set and Get Methods for Dependent Properties
    Dependent properties need access methods because these properties do not store values. Property access methods manage interactions with the dependent properties.

Dynamic Properties