| 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… |
|---|
Counting Departures Across the Simulation Counting Departures per Time Instant |
Use the #d or #a output signal from a block to learn how many entities have departed from (or arrived at) a particular block. The output signal also indicates when departures occurred. This method of counting is cumulative throughout the simulation. These examples use the #d output signal to count departures:
Suppose you want to visualize entity departures from a particular block, and you want to reset (that is, restart) the counter at each time instant. Visualizing departures per time instant can help you:
Detect simultaneous departures
Compare the number of simultaneous departures at different time instants
Visualize the departure times while keeping the plot axis manageable
Use the Instantaneous Entity Counting Scope to plot the number of entities that have arrived at each time instant. The block restarts the count from 1 when the time changes. As a result, the count is cumulative for a given time instant, but not cumulative across the entire simulation.
In this example (open model), the Infinite Server block sometimes completes service on multiple entities simultaneously. The Instantaneous Entity Counting Scope indicates how many entities departed from the server at each fixed time instant during the simulation.



Suppose you want to count entities that depart from a particular block, and you want to reset the counter at arbitrary times during the simulation. Resetting the counter can help you compute statistics for evaluating your system over portions of the simulation.
The Entity Departure Counter block counts entity departures via a resettable counter. To configure the block:
Decide which type of events you want to reset the counter. The choices are:
Sample time hits
Trigger edges
Value changes
Function calls
These resources can help you choose which type of events:
To learn the difference among the kinds of signal-based events, see Signal-Based Events and Function Calls.
To build a signal that has events at the times that you need them, see Manipulating Events.
To visualize the events of a signal, use the Instantaneous Event Counting Scope block.
In the Entity Departure Counter block, indicate which signal-based events cause the counter to reset:
To reset upon sample time hits of an input signal, set Reset counter upon to Sample time hit from port ts.
To reset based on a trigger edge in an input signal, set Reset counter upon to Trigger from port tr. Then set Trigger type to Rising, Falling, or Either.
To reset based on a change in the value of an input signal, set Reset counter upon to Change in signal from port vc. Then set Type of change in signal value to Rising, Falling, or Either.
To reset upon function calls, set Reset counter upon to Function call from port fcn.
If you want to specify an explicit priority for the reset event, select Resolve simultaneous signal updates according to event priority. Then enter the priority using the Event priority parameter.
Click OK or Apply. The block now has a signal input port.
Connect a signal to the signal input port.
During the simulation, the block counts departing entities and resets its counter whenever the input signal satisfies your specified event criteria.
This example (open model) counts entity departures from a queuing system, but resets the counter after an initial transient period.


Use the Entity Departure Counter block with Write count to attribute set to On to associate entity counts with the entities that use a particular path. The Nth entity departing from the Entity Departure Counter block has an attribute value of N.
For an example, see Example: Setting Attributes.
For an example in which the Entity Departure Counter block is more straightforward than storing the #d output signal in an attribute, see Example: Sequence of Departures and Statistical Updates.
![]() | Accessing Attributes of Entities | Combining Entities | ![]() |

Learn how you can use SimEvents discrete-event simulation capbilities through these technical resources.
Get free kit| © 1984-2010- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |