Working with Entity Attributes

You can attach data to an entity using one or more attributes of the entity. Each attribute has a name and a numeric value. You can read or change the values of attributes during the simulation.

For example, suppose your entities represent a message that you are transmitting across a communication network. You can attach the length of each particular message to the message itself using an attribute named length.

You can also use attributes to specify the amount of a resource for your model. For more information, see Model with Resources.

Attach Attributes

To attach attributes to an entity, use the Entity Generator block. Attribute attachments can create new attributes or change the values of existing attributes. You can attach attributes such as:

  • Constant value

  • Random numbers

  • Elements of either a vector in the MATLAB® workspace or a vector that you can type in a block dialog box

  • Values of an output argument of a MATLAB function that you write

  • Values of a signal

  • Outputs of a function defined in Simulink® or Stateflow® environment that you write.

Set Attributes

To build and manage the list of attributes to attach to each departing entity, use the controls under the Define attributes section of the Entity Generator block. Each attribute appears as a row in a table.

Using these controls, you can:

  • Add an attribute manually to attach to the entity.

  • Modify an attribute that you added to the table from the Available Attributes list to attach to the entity.

The buttons under Set Attribute perform these actions.


Add a template attribute to the table.

Rename the attribute and specify its properties.

Remove the selected attribute from the attribute table.

When you delete an attribute this way, no confirmation appears and you cannot undo the operation.

The table displays the attributes you added manually. Use it to set these attribute properties.


Attribute Name

The name of the attribute. Each attribute must have a unique name.

Double-click the existing name, and then type the new name.

Attribute Initial Value

The value to assign to the attribute (when the attribute comes from the dialog box).

Double-click the value, and then type the value you want to assign.

See Also

| |

Related Examples

More About

Was this topic helpful?