Count Entities
Using statistics, you can count entities across the simulation and per time instant.
Count Departures Across the Simulation
Use the d or a output from a block to learn how many entities have departed (or arrived at) the block. The output signal also indicates when departures occurred. This method of counting is cumulative throughout the simulation.
Count Departures per Time Instant
Suppose that 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
For an example of counting simultaneous departures from a server in a cumulative way, see Count Simultaneous Departures from a Server.
For an example of noncumulative counting of entity arrivals, see Noncumulative Counting of Entities.
Reset a Counter upon an Event
Suppose that 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.
During the simulation, the block counts departing entities and resets its counter whenever the input signal satisfies your specified event criteria.
Associate Each Entity with Its Index
To associate an entity with its index, in the initialization section of the Entity Generator block, you can associate an entity with its generation time:
Use a Simulink Function block with a clock block, such as Digital Clock, to create a Simulink® function.
This function returns the current time.
In the Entity Generator block, create an attribute and associate it with the current time that the Simulink function returns.
For an example, see Time stamp entities upon generation in the SimEvents® Design Patterns sublibrary.