| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → SimEvents |
| Contents | Index |
| Learn more about SimEvents |
| On this page… |
|---|
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.
In some modeling situations, it is important to attach data to an entity instead of merely creating the data as the content of a signal. The next example shows the importance of considering not only the topology of your block diagrams, but also the timing of data signals.
Consider a queue-server example (open model) with varying service times. Suppose you want to plot the service time against entity count for each entity departing from the server. A signal specifies the service time to use for each entity. Although connecting the same signal to the Signal Scope block appears correct topologically, the timing in such an arrangement is incorrect. The incorrectness arises from the delay at the server. That is, the signal has one value when a given entity arrives at the server and another value when the same entity arrives at the scope.
To implement the example correctly, attach the service time to each entity using an attribute and retrieve the attribute value when needed from each entity. That way, the scope receives the service time associated with each entity, regardless of the delay between arrival times at the server and the scope.

To assign attributes on each arriving entity, use one of the blocks in the next table.
| Block | Attribute Value | For More Information |
|---|---|---|
| Attribute Function | Value of output argument from a function you write | Writing Functions to Manipulate Attributes |
| Set Attribute | Signal value or information you enter in the block dialog box | Set Attribute block reference page |
| Entity Departure Counter | Entity count, only if you set Write count to attribute to On. | Associating Each Entity with Its Index |
| Single Server | Residual service time, only for preempted entities | Preempting an Entity in a Server |
Assignments can create new attributes or change the values of existing attributes.
To learn how to query entities for attribute values, see Accessing Attributes of Entities. To learn how to aggregate attributes from distinct entities, see Combining Entities.
These lists summarize the characteristics of attribute values.
Permitted Characteristics of Attribute Values
Real or complex
Array of any dimension
double data type
For a given attribute, the characteristics of the value must be consistent throughout the model.
Not Permitted as Attribute Values
Frame
Structure
Data types other than double. In particular, strings are not valid as attribute values.
Buses
This example (open model) illustrates different ways of assigning attribute values to entities.

After each entity departs from the Attribute Function block, it possesses the attributes listed in the table.
| Attribute Name | Attribute Value | Method for Setting Attribute Value | |||
|---|---|---|---|---|---|
| Count | N, for the Nth entity departing from the Time-Based Entity Generator block | In Entity Departure Counter dialog box:
Actually, the entity generator creates the Count attribute with a value of 0. The Entity Departure Counter block sets the attribute value according to the entity count. | |||
| Type | Constant value of 3 | A1 row of table in Set Attribute dialog
box:
| |||
| Length | Next number in the sequence produced by Event-Based Sequence block | Event-Based Sequence block connected to Set
Attribute block in which A2 row of table
in dialog box is configured as follows:
| |||
| LengthInt | floor(Length) | Attribute Function block whose function isfunction [out_LengthInt] = fcn(Length) out_LengthInt = floor(Length); |
In this example, each Attribute Scope block plots values of a different attribute over time. Notice from the vertical axes of the plots below that the Count values increase by 1 with each entity, the Type values are constant, and the Length values show cyclic repetition of a sequence. For brevity, the example does not plot LengthInt values, which would look similar to Length values.



![]() | Specifying Generation Times for Entities | Manipulating Attributes of Entities | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |