| 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… |
|---|
Behavior of the Discrete Event Signal to Workspace Block |
The Discrete Event Signal to Workspace block writes event-based signals to the MATLAB workspace when the simulation stops or pauses. One way to pause a running simulation is to select Simulation > Pause. When inside a discrete event subsystem, the To Workspace block can also be useful for writing event-based signals to the MATLAB workspace.
Note To learn how to read data from the workspace during a discrete-event simulation, see Using Data Sets to Create Event-Based Signals. |
The example below (open model) shows one way to write the times and values of an event-based signal to the MATLAB workspace. In this case, the signal is the #n output from a FIFO Queue block, which indicates how many entities the queue holds.

After you run this simulation, you can use the following code to create a two-column matrix containing the time values in the first column and the signal values in the second column.
times_values = [num_in_queue.time, num_in_queue.signals.values]
The output below reflects the Time-Based Entity Generator block's constant intergeneration time of 0.8 second and the Single Server block's constant service time of 1.1 second.
times_values =
0 0
0.8000 1.0000
1.1000 0
1.6000 1.0000
2.2000 0
2.4000 1.0000
3.2000 2.0000
3.3000 1.0000
4.0000 2.0000
4.4000 1.0000
4.8000 2.0000
5.5000 1.0000
5.6000 2.0000
6.4000 3.0000
6.6000 2.0000
7.2000 3.0000
7.7000 2.0000
8.0000 3.0000
8.8000 4.0000
8.8000 3.0000
9.6000 4.0000
9.9000 3.0000From the output, you can see that the number of entities in the queue increases at times that are a multiple of 0.8, and decreases at times that are a multiple of 1.1. At T=8.8, a departure from the server and an entity generation occur simultaneously; both events influence the number of entities in the queue. The output shows two values corresponding to T=8.8, enabling you to see the zero-duration value that the signal assumes at this time.
The To Workspace block in the Simulink Sinks library can be useful for working with event-based signals in special ways, such as
Omitting repeated values of the signal and focusing on changes in the signal's value. For an example, see Example: Sending Unrepeated Data to the MATLAB Workspace.
Recording values of multiple signals when any one of the signals has an update. To accomplish this, place multiple To Workspace blocks in a discrete event subsystem that has multiple input ports.
If you use the To Workspace block in the Simulink Sinks library to write event-based signals to the MATLAB workspace, you should
Set the block's Save format parameter to Structure With Time, which causes the block to record time values, not just signal values.
Place the To Workspace block in a discrete event subsystem to ensure that the workspace variable records data at appropriate times during the simulation.
For more details about discrete event subsystems, see Role of Discrete Event Subsystems in SimEvents Models.
![]() | Manipulating Signals | Working with Multivalued Signals | ![]() |

Model electronic system architectures, process flows, and logistics as queuing systems or agent-based systems.
Get free kit| © 1984-2010- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |