Real-Time Workshop | ![]() ![]() |
Workspace I/O Options and Data Logging
This section discusses several different methods by which a Real-Time Workshop generated program can save data to a MAT-file for later analysis. These methods include
Tutorial 2: Data Logging of the Real-Time Workshop Getting Started Guide is an exercise designed to give you hands-on experience with data logging features of Real-Time Workshop.
Logging States, Time, and Outputs via the Workspace I/O Pane
The Workspace I/O pane enables a generated program to save system states, outputs, and simulation time at each model execution time step. The data is written to a MAT-file, named (by default) model
.mat
.
Before using this data logging feature, you should learn how to configure a Simulink model to return output to the MATLAB workspace. This is discussed in the Simulink documentation.
For each workspace return variable that you define and enable, Real-Time Workshop defines a MAT-file variable. For example, if your model saves simulation time to the workspace variable tout
, your generated program will log the same data to a variable named (by default) rt_tout.
Real-Time Workshop logs the following data:
rt_yout
.
The sort order of the rt_yout
array is based on the port number of the Outport block, starting with 1.
Real-Time Workshop data logging follows the Workspace I/O Save options: (Limit data points, Decimation, and Format).
Overriding the Default MAT-File Name. The MAT-file name defaults to model
.mat.
To specify a different filename:
Overriding Default MAT-File Variable Names. By default, Real-Time Workshop prepends the string rt_
to the variable names for system outputs, states, and simulation time to form MAT-file variable names. To change this prefix:
rt_
) or suffix (_rt
) from the MAT-file variable name modifier field, or choose none
for no prefix.
Logging Data with Scope and To Workspace Blocks
Real-Time Workshop also logs data from these sources:
The variables are written to model
.mat
, along with any variables logged from the Workspace I/O pane.
Logging Data with To File Blocks. You can also log data to a To File block. The generated program creates a separate MAT-file (distinct from model
.mat
) for each To File block in the model. The file contains the block's time and input variable(s). You must specify the filename, variable name(s), decimation, and sample time in the To File block's dialog box.
Note that the To File block cannot be used in DOS real-time targets because of limitations of the DOS target.
Data Logging Differences in Single- and Multitasking Models
When logging data in singletasking and multitasking systems, you will notice differences in the logging of
In multitasking mode, the logging of states and outputs is done after the first task execution (and not at the end of the first time step). In singletasking mode, Real-Time Workshop logs states and outputs after the first time step.
See Data Logging In Singletasking and Multitasking Model Execution for more details on the differences between single- and multitasking data logging.
Note
The rapid simulation target (rsim ) provides enhanced logging options. See Real-Time Workshop Rapid Simulation Target for more information.
|
![]() | Solver Options | Diagnostics Pane Options | ![]() |