Contenuto principale

Proprietà

R2026b
Dichiarazione di proprietà, attributi e metodi di accesso

Le proprietà contengono i dati dell’oggetto. Le classi definiscono le stesse proprietà per tutti gli oggetti, ma ogni oggetto può avere valori di dati unici. Gli attributi delle proprietà controllano quali funzioni o metodi possono accedere alla proprietà. È possibile definire funzioni che vengono eseguite ogni volta che vengono impostati o interrogati i valori della proprietà. Le proprietà possono attivare eventi quando il codice accede ai loro valori.

Funzioni

espandi tutto

propertiesClass property names
ispropDetermine if property is defined by object

Validazione dell'attributo del valore numerico

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 input does not contain NaN
mustBeNonzeroValidate that value is nonzero
mustBeNonsparseValidate that value is nonsparse
mustBeSparseValidate that value is sparse (Da R2023b)
mustBeRealValidate that value is real
mustBeIntegerValidate that value is integer
mustBeNonmissingValidate that input does not contain missing values

Validazione del confronto

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
mustBeSortedValidate that input is sorted (Da R2026a)

Impostazione dell'appartenenza a un insieme e validazione dell'intervallo

mustBeMemberValidate that value is member of specified set
mustBeBetweenValidate that all elements are within specified range (Da R2025a)

Validazione del tipo di dati

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

Validazione della dimensione

mustBeNonemptyValidate that value is nonempty
mustBeScalarValidate that value is scalar (Da R2026b)
mustBeScalarOrEmptyValidate that value is scalar or empty
mustBeVectorValidate that value is vector
mustBeVectorOrEmptyValidate that value is vector or empty (Da R2026b)
mustBeRowValidate that value is row vector (Da R2024b)
mustBeColumnValidate that value is column vector (Da R2024b)
mustBeMatrixValidate that value is matrix (Da R2024b)

Testo con validazione del significato specifico

mustBeFileValidate that path refers to file
mustBeFolderValidate that input path refers to folder
mustBeFilePathInclusiveValidate that input is file in current folder, specified location, or MATLAB path (Da R2026b)
mustBeSymbolicLinkValidate that input is symbolic link (Da R2026b)
mustBeValidVariableNameValidate that input name is valid variable name

Classi

dynamicpropsSuperclass for classes that support dynamic properties
matlab.metadata.DynamicPropertyDescribe dynamic property of MATLAB object
event.DynamicPropertyEventEvent data for dynamic property events
matlab.metadata.PropertyDescribe property of MATLAB class
matlab.metadata.PropertyValidation Describe 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.OnOffSwitchStateRepresent on and off states with logical values

Argomenti

Definizione delle proprietà e impostazione degli attributi

Validazione delle proprietà

Metodi di accesso alle proprietà

Proprietà dinamiche