| SimEvents® | ![]() |
SimEvents User-Defined Functions
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.
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. |
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 Operation | Block |
|---|---|
| Switching based on the same attribute that the Attribute Function block created or modified | Output Switch block with Switching criterion=From attribute |
| Preemption based on the same attribute that the Attribute Function block created or modified | Single Server block with Permit preemption based on attribute selected |
Entity Input Ports
| Label | Description |
|---|---|
| IN | Port for arriving entities. |
Entity Output Ports
| Label | Description |
|---|---|
| OUT | Port for entities whose attributes the block accessed, created, or modified. |
Distributed Processing for Multi-Class Jobs demo, within the Distribution Center subsystem and its Service History Monitor subsystem
Writing Functions to Manipulate Attributes
![]() | Blocks — Alphabetical List | Attribute Scope | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |