Attribute Function

Access and modify attributes using MATLAB code




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.

This block corresponds to a function that you write in an editor window that opens when you double-click the block. Your function names the attributes you want to access, modify, or create. When writing your function, you can use any part of the MATLAB® language that is suitable for code generation, subject to the argument-naming rules described in Write Functions to Manipulate Attributes and the attribute support described in Attribute Value Support.

    Note:   If you attach large arrays to entities in a model that contains a server or a queue block with large capacity, the simulation could run out of memory.

Timing and Connections

In most cases, it is not necessary to introduce a storage block between the Attribute Function block and subsequent blocks that use attributes (for example, Attribute Scope). However, the next table indicates exceptional cases in which you should insert a Single Server block between the Attribute Function block and the block performing the subsequent operation.

Subsequent OperationBlock
Switching based on the same attribute that the Attribute Function block created or modifiedOutput Switch block with Switching criterion=From attribute
Preemption based on the same attribute that the Attribute Function block created or modifiedSingle Server block with Permit preemption based on attribute selected


Entity Input Ports

INPort for arriving entities.

Entity Output Ports

OUTPort for entities whose attributes the block accessed, created, or modified.

Was this topic helpful?