Main Content

Set Scope Parameters for Logging to Workspace

Data is saved to the MATLAB® workspace through a Simulink® Scope block. For data to be saved, set Scope block parameters. After you create a Simulink model and add a Scope block, you can enter the scope parameters for signal logging to the MATLAB workspace.

This procedure uses the model sldrtex_model. To open this model, in the MATLAB Command Window, type:

openExample('sldrtex_model')

It assumes that you have already loaded that model.

  1. In the Simulink Editor, on the Desktop Real-Time tab, select Mode > Run in Kernel.

  2. In the model diagram, double-click the Scope block.

  3. On the Scope toolbar, click the Parameters button .

  4. In the Scope Parameters dialog box, click the Logging tab.

  5. Do one of the following:

    • If you are running a normal mode simulation in Connected IO mode, select the Limit data points to last check box, and enter the number of sample points to save.

    • If you are running an external mode simulation in Run in Kernel mode, do not select the Limit data points to last check box.

    When you are using Simulink Desktop Real-Time™ software, use the Duration value to set the number of sample points you save. To set the Duration value, see Set Run in Kernel Mode Properties for Logging to Workspace. For more information, see External Mode Simulation with TCP/IP or Serial Communication (Simulink Coder).

  6. Select the Log data to workspace check box. In the Variable name text box, enter the name of a MATLAB variable. The default name is ScopeData.

  7. From the Save format list, select one of Structure with time, Structure, Array, and Dataset. For example, to save the sample times and signal values at those times, select Structure with time.

    The scope parameters data appears in the configuration properties window.

  8. Click OK.

    When you modify a value in the Scope parameters dialog box, you must click the Apply or OK button for the changes to take effect. Rebuild your real-time application before connecting and starting it. If you do not rebuild, an error dialog box opens. If you do not click Apply, your executable runs, but it uses the old settings.

Related Topics