Attribute Function - Access and modify attributes using Embedded MATLAB™ code

Library

SimEvents User-Defined Functions

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.

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 Embedded MATLAB subset of the MATLAB® language, subject to the argument-naming rules described in Writing Functions to Manipulate Attributes and the attribute support described in Attribute Value Support.

Timing and Connections

The Attribute Function block automatically ensures that the computation and the reassignment of the attribute value use the correct timing. It is not necessary to use a discrete event subsystem in conjunction with the Attribute Function block.

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

Ports

Entity Input Ports

LabelDescription
INPort for arriving entities.

Entity Output Ports

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

Examples

See Also

Set Attribute, Get Attribute

Writing Functions to Manipulate Attributes

  


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