Documentation Center

  • Trial Software
  • Product Updates

Set Entity Attributes

Role of Attributes in SimEvents Models

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.

Blocks That Set Attributes

To attach attributes to an entity, use one of the blocks listed in the following table. Attribute attachments can create new attributes or change the values of existing attributes.

Data to AttachBlocks to UseMore Information and Examples
Constant valueSet Attribute
Set Attribute block reference page
Set Attributes
Random numbersEvent-Based Random Number followed by Set Attribute
Generate Random Signals
Set Attribute block reference page
Model a Packet Switch
Elements of either a vector in the MATLAB® workspace or a vector that you can type in a block dialog boxEvent-Based Sequence followed by Set Attribute
Create Event-Based Signals Using Data Sets
Set Attribute block reference page
Set Attributes
Values of an output argument of a MATLAB function that you writeAttribute Function, or MATLAB Function followed by Set Attribute
Write Functions to Manipulate Attributes
Set Attributes
Values of an event-based signalSet Attribute
Set Attribute block reference page
Communication Protocol Modeling in an Ethernet LANCommunication Protocol Modeling in an Ethernet LAN example, in MAC Controller subsystems
Values of a time-based signalSet Attribute preceded by Timed to Event Signal
Set Attribute block reference page
Time-Based and Event-Based Signal Conversion
Build a Hybrid Model
Entity countEntity Departure Counter with Write count to attribute check box selected
Associate Each Entity with Its Index
Set Attributes

For Further Information

Set Attributes

This example (open modelmodel) 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 NameAttribute ValueMethod for Setting Attribute Value
CountN, for the Nth entity departing from the Time-Based Entity Generator blockIn Entity Departure Counter dialog box:
Write count to attribute check box selected
Attribute name = Count

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.

TypeConstant value of 3A1 row of table in Set Attribute dialog box:
Name = Type
Value From = Dialog
Value = 3
LengthNext number in the sequence produced by Event-Based Sequence blockEvent-Based Sequence block connected to Set Attribute block in which A2 row of table in dialog box is configured as follows:
Name = Length
Value From = Signal port
LengthIntfloor(Length)Attribute Function block whose function is
function [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.

Attach Data Instead of Branching a Signal

In some modeling situations, it is important to attach data to an entity instead of using a signal directly. This example (open modelmodel) shows the importance of considering not only the topology of your block diagrams, but also the timing of data signals.

The model contains a server with varying service times. Suppose you want to plot the service time against entity count for each entity departing the server. A ramp 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.

Was this topic helpful?