MATLAB: How to export simulink data to workspace during simulation

MATLABsimulationsimulink

Hi, I want to retrieve the data from simulink during simulation, and use serial function to send these data to other applications.
I've tried using To Workspace block to export the data.
However, I can only got value in the very beginning of the simulation.
I've found this page http://www.mathworks.com/help/simulink/ug/exporting-simulation-data.html, but I still don't know how to continuously export data during simulation.
EDIT: Use scope and change some properties: check Save Data To Workspace and Uncheck Limite data to Last seems to be getting the data from simulink when the simulation stop.
First, I started simulation, and I found the ScopeData didn't appear in the Workspace. Only when I stop simulation, ScopeData would appear in workspace.
And after that, I can use ScopeData.signals.values to get values.
But what I want is: when I start simulation, ScopeData would appear in workspace so that I can send these data to other program.
Does anyone know how to achieve this?

Best Answer

There are several ways to export your data to workspace
  1. you can use a scope where you will change some properties: check Save Data To Workspace and Uncheck Limite data to Last
  2. Use a to Workspace Block
  3. Use a to File block, which you can load after simulation