MATLAB: Do the initial values of a signal exported with a Simulink “To Workspace” block persist even after I pause the simulation and clear the variable

deletepausesimulinkstop

I have a Simulink model that uses a "To Workspace" block to send a signal to the MATLAB workspace.
When I fo the following:
1. Pause the model halfway through the simulation
2. Clear the workspace variable that corresponds to the signal
3. Restart the model and let it finish
4. Examine the workspace variable
I find that the variable contains the samples from the entire simulation run, not just those from the second half, as I would expect.

Best Answer

The "To Workspace" block internally queues the samples of the signal that will be exported to the workspace, and simply copies those samples to the workspace variable when the simulation is stopped or paused.
This is why clearing the workspace variable--or modifying it in any other way--has no effect on the values seen the next time the simulation is paused or stopped.