Manipulate Entity Attributes

The attributes table describes some ways that you can use data that you have attached to an entity.

  • Create a signal

  • Create a plot

  • Compute a different attribute value

  • Help specify behavior of a block that supports the use of attribute values for block parameters. Examples are the service time for a server and the selected port for an output switch.

Suppose that your entity possesses an attribute with one of these quantities:

  • Service time to be used by a downstream server block

  • Switching criterion to be used by a downstream switch block

When an entity with one of these attribute quantities arrives at a server or switch block, you can directly reference the attribute using an option on the server or switch block dialog box.

Write Functions to Manipulate Attributes

To manipulate attributes using code, use the Event actions tab of a block. In this tab, you can write MATLAB® code to manipulate the attribute. To access the attribute, use the notation entityName.attributeName. For example:


For example, you might want to manipulate the attributes for service completion.

  1. In a new model, from the SimEvents® library, drag the Entity Generator, Entity Server, and Entity Terminator blocks and connect them.

  2. Double-click Entity Generator and, in the Entity type tab, add three attributes to the attributes table.

  3. In the Entity Server block, click the Event actions tab.

  4. For the Service complete action, enter MATLAB code to manipulate the entity attributes you added in the Entity Generator block. For example:

    This code updates the Entity Server block with the event action icon.

  5. To see the action, in the model, hover over the Entity Server block event action icon block.

See Also

| |

Related Examples

More About