Set Scope Parameters for Logging to File
You save data to a file by first saving the data 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 a file.
This procedure uses the model
sldrtex_model. To open this model, in
the MATLAB Command Window, type:
It assumes that you have already loaded that model.
In the Simulink Editor, on the Desktop Real-Time tab, select Mode > Run in Kernel.
In the model diagram, double-click the Scope block.
On the Scope toolbar, click the Parameters button .
Click the Logging tab.
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 File. For more information, see External Mode Simulation with TCP/IP or Serial Communication (Simulink Coder).
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
In the Scope parameters dialog box, you must select the Log data to workspace check box to be able to save data to a file. If you do not select the Log data to workspace check box, the MAT-files for data logging are created, but they are empty.
From the Save format list, select one of
Structure with time,
Dataset. For example, to save the sample times and signal values at those times, select
Structure with time.
Before connecting and starting the application with changed settings, rebuild your real-time application. If you do not rebuild after these changes, an error occurs.