| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → SimEvents |
| Contents | Index |
| Learn more about SimEvents |
| On this page… |
|---|
The Event-Based Entity Generator block enables you to generate entities in response to signal-based events that occur during the simulation. The Generate entities upon parameter of the block determines:
The kind of signal input port the block has
The kinds of events that cause the block to generate an entity
Event times and the time intervals between pairs of successive entities are not necessarily predictable in advance.
Note The Event-Based Entity Generator block can respond to triggers and function calls. However, do not place the block inside a triggered or function-call subsystem. Like other blocks that possess entity ports, the Event-Based Entity Generator block is not valid inside a triggered or function-call subsystem. |
To specify intergeneration times between pairs of successive entities instead of using an event-based approach, use the Time-Based Entity Generator block. For more information, see Creating Entities Using Intergeneration Times.
Generating entities when events occur is appropriate if you want the dynamics of your model to determine when to generate entities. For example,
To generate an entity each time the length of a queue changes, configure the queue to output a signal indicating the queue length. Then configure the Event-Based Entity Generator block to react to changes in the value of that signal.
To generate entities periodically, configure the Event-Based Entity Generator block to react to sample time hits of a discrete-time signal with an explicit Sample time parameter. Regardless of the value of the signal, the block generates an entity periodically, according to the sample time of the driving block.

Another way to generate entities periodically is to use a Time-Based Entity Generator block with Distribution set to Constant. The advantage of using the Event-Based Entity Generator is that it more directly synchronizes entity generation events with sample time hits and avoids possible roundoff errors.
For other examples that use this entity-generation method to create desired simultaneity of events, see Example: Choices of Values for Event Priorities.
To generate an entity each time a Stateflow® chart transitions from state A to state B, configure the chart to output a function call upon such a transition. Then configure the Event-Based Entity Generator block to react to each function call by generating an entity.
To generate an entity each time a real-valued statistical signal crosses a threshold, configure the Event-Based Entity Generator block to react to triggers. Connect the tr signal input port of the block to the statistical signal minus the threshold. If the statistical signal is an event-based signal, then perform the subtraction in a discrete event subsystem; see Timing Issues in SimEvents Models for details.
In the following figure, the Event-Based Entity Generator block generates a new entity each time the average waiting time of the queue crosses a threshold. The threshold is 5 s.
Top-Level Model

The subsystem between the queue and the entity generator adds -5 to the average waiting time value to translate the threshold from 5 to 0.
Subsystem Contents

To generate multiple entities simultaneously, configure the Event-Based Entity Generator block to react to function calls. Then connect its fcn input port to a signal that represents multiple function calls. For an example, see the Preload Queue with Entities demo.
Note If you generate multiple entities simultaneously, then consider the appropriateness of other blocks in the model. For example, if three simultaneously generated entities advance to a single server, then consider inserting a queue between the generator and the server. As a result, entities (in particular, the second and third entities) have a place to wait for the server to become available. |
![]() | Working with Entities | Specifying Generation Times for Entities | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |