Set Attribute - Assign data to entity

Library

Attributes

Description

This block accepts an entity, assigns data to it, and then outputs it. Assigned data is stored in attributes of the entity, where each attribute has a name and a value. See Attribute Value Support to learn what kind of data an attribute can store.

Manipulating the Rows of the Table

Each attribute corresponds to a row in the table on the Set Attribute tab in the block's dialog box. Buttons to the left of the table let you manipulate rows in the table:

Configuring Individual Rows to Set Particular Attributes

Within each row, you can specify properties of the attribute that corresponds to that row.

Assigning a Constant Value Using the Block Parameters Dialog Box

  1. Select the Name field and type the name of the attribute you want to set. All names that would be valid variable names in the MATLAB® language, except nan and inf (with any use of case), are valid as attribute names. To determine whether a name is a valid variable name, use the isvarname function.

  2. Set Value From to Dialog.

  3. Select the Value field and enter the value for the attribute.

  4. Determine if the constant value you typed is a vector that you want the block to interpret a one-dimensional array rather than a multidimensional array. If yes, select Treat Vector as 1-D.

Assigning a Value Using an Input Signal

  1. Select the Name field and type the name of attribute you want to set. All names that would be valid variable names in the MATLAB language, except nan and inf (with any use of case), are valid as attribute names. To determine whether a name is a valid variable name, use the isvarname function.

  2. Set Value From to Signal port. The Value and Treat Vector as 1-D fields become disabled.

  3. Click OK or Apply. The block now has a signal input port whose label matches the label to the left of the row of the table (A1, A2, etc.).

  4. Connect a signal to the Ax input port. During the simulation, the block assigns the value of this signal to the attribute. The signal must be sample-based instead of frame-based.

Ports

Entity Input Ports

LabelDescription
INPort for arriving entities.

Signal Input Ports

LabelDescription
AxData to assign for the attribute specified in the Ax row of the table in the dialog box. This port appears only if you set Value From in the Ax row to Signal port.

Entity Output Ports

LabelDescription
OUTPort for departing entities, with data assigned to them.

Signal Output Ports

LabelDescriptionTime of Update When Statistic Is On
#dNumber of entities that have departed from this block since the start of the simulation.After entity departure

The initial output value, which is in effect from the start of the simulation until the first update by the block, is 0.

Dialog Box

Set Attribute Tab

Name

The name of the attribute to set.

Value From

Determines whether the data for attribute values comes from the dialog or a signal.

Value

The value to assign to the attribute. This field is active only if you set Value From to Dialog.

Treat Vector as 1-D

This option affects attributes whose Value From parameter is set to Dialog and whose Value parameter evaluates to an N-element row or column vector. Selecting this option causes the block to assign the attribute as a vector of length N. Otherwise, the block assigns the attribute as a multidimensional array.

Create attribute if not present

Selecting this option enables the block to define new attributes. Otherwise, the block issues an error if any attribute named in the table does not already exist.

Statistics Tab

These parameters determine whether certain ports produce data throughout the simulation, produce data only when you stop or pause the simulation, or are omitted from the block. For descriptions of the affected ports, see the "Signal Output Ports" table above.

Number of entities departed

Controls the presence and behavior of the signal output port labeled #d.

Examples

See Also

Get Attribute

Setting Attributes of Entities

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS