Main Content

addProperty

Define custom property for stereotype

Description

property = addProperty(stereotype,name) returns a new property definition with name that is contained in stereotype.

To remove a property, use the removeProperty function.

example

property = addProperty(stereotype,name,Name=Value) returns a property definition that is configured with specified name-value arguments.

example

Examples

collapse all

Add a component stereotype and add a VoltageRating property.

profile = systemcomposer.profile.Profile.createProfile("myProfile");
stereotype = addStereotype(profile,"electricalComponent",AppliesTo="Component");
property = addProperty(stereotype,"VoltageRating");

Add a component stereotype and add a Status property with the default value "active".

profile = systemcomposer.profile.Profile.createProfile("myProfile");
stereotype = addStereotype(profile,"electricalComponent",AppliesTo="Component");
property = addProperty(stereotype,"Status",type="string",DefaultValue='"active"');

Add a component stereotype.

profile = systemcomposer.profile.Profile.createProfile("myProfile");
stereotype = addStereotype(profile,"DataConnector",AppliesTo="Connector");

In a separate file, create a ConnectorType enumeration class.

classdef ConnectorType < Simulink.IntEnumType
  enumeration
    USB(0)
    Ethernet(1)
    RS232(2) 
  end
end 

Add a TypeOfConnection property with Type set to newly created ConnectorType data type.

property = addProperty(stereotype,"TypeOfConnection",type="ConnectorType");

Input Arguments

collapse all

Stereotype, specified as a systemcomposer.profile.Stereotype object.

Name of property unique within the stereotype, specified as a character vector or string.

Data Types: char | string

Name-Value Arguments

collapse all

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: addProperty(stereotype,"Amount",Type="double")

Type of this property. One of valid data types or the name of a MATLAB class that defines an enumeration. For more information, see Use Enumerated Data in Simulink Models.

Example: addProperty(stereotype,"Color",Type="BasicColors")

Data Types: char | string

Dimensions of property, specified as a positive integer array. Empty implies no restriction.

Example: addProperty(stereotype,"Amount",Dimensions=2)

Data Types: double

Optional minimum value of this property. To set both 'Min' and 'Max' together, use the setMinAndMax method.

Example: setMinAndMax(property,min,max)

Example: addProperty(stereotype,"Amount",Min="0")

Data Types: double

Optional maximum value of this property. To set both 'Min' and 'Max' together, use the setMinAndMax method.

Example: setMinAndMax(property,min,max)

Example: addProperty(stereotype,"Amount",Max="100")

Data Types: double

Units of the property value, specified as a character vector or string. If specified, all values of this property on model elements are checked for consistency with these units according to Simulink unit checking rules. For more information, see Unit Consistency Checking and Propagation.

Example: addProperty(stereotype,"Amount",Units="kg")

Data Types: char | string

Default value of this property, specified as a character vector or string that can be evaluated depending on the Type.

Data Types: char | string

Output Arguments

collapse all

Created property, returned as a systemcomposer.profile.Property object.

More About

collapse all

Version History

Introduced in R2019a