Send Data to the MATLAB Workspace

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.

Send Queue Length to the Workspace

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 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. The first row of the times_values matrix represents the initial value of the #n signal.

times_values =

         0         0
         0    1.0000
         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.0000

From 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.

Was this topic helpful?