title: How to export simulink data to workspace during simulation?
body: <p>I want to retrieve the data from simulink <strong>during simulation</strong>, and use serial network function to send these data to another program. Because I need to use another program to do some tricks and send command back to simulink, so I have to get data from simulink during runtime so that another program can make the right command.</p>
  
  <p>I've tried using To Workspace block to export the data.</p>
  
  <p><img src="https://i.stack.imgur.com/stRaF.png" alt="enter image description here"></p>
  
  <p>However, I can only got value in the very beginning of the simulation.</p>
  
  <p>And I've also tried using scope and change some properties: check Save Data To Workspace and Uncheck Limite data to Last. </p>
  
  <p><img src="https://i.stack.imgur.com/7Pg9W.png" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/VmsPj.png" alt="enter image description here"></p>
  
  <p>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.</p>
  
  <p><img src="https://i.stack.imgur.com/W6wYC.png" alt="enter image description here"></p>
  
  <p>And after that, I can use ScopeData.signals.values to get values.</p>
  
  <p>But what I want is: when I start simulation, ScopeData would appear in workspace so that I can send these data to other program.</p>
  
  <p>Does anyone know how to achieve this?</p>
  
  <p>I found <a href="http://www.mathworks.com/help/simulink/ug/exporting-simulation-data.html" rel="noreferrer">this page</a> might be helpful, but I still don't know how to continuously export data during simulation.</p>