User`s guide
5 Data Logging and Signal Monitoring
5-2
MAT-File Data Logging
For the Real-Time Workshop targets that have access to a disk, you can use
MAT-file logging to examine the results of the real-time program.
Real-Time Workshop targets can create a MAT-file that logs system states and
outputs at each model execution time step. Some provide more options than
others; for example, the rapid simulation target (
rsim) provides enhanced
logging configurations. See Chapter 13, “Real-Time Workshop Rapid
Simulation Target,” for more information.
By using the Workspace I/O page of the Simulation parameters dialog box,
you can select time, state, and outputs to log as well as the decimation desired.
The default variable names used in the MAT-file are
rt_tout, rt_xout,and
rt_yout respectively. The Real-Time Workshop logs outputs for:
• All root Outport blocks (
rt_yout)
• All Scopes that have s
ave data to workspace selected
• All To Workspace blocks in the model
For Scope and To Workspace blocks, you must specify variable names in each
block’s dialog box. You can log states for all continuous and discrete states in
the model. The sort order of the
rt_yout array is based on the port number of
the Outport block, starting with 1. You can determine the sort order of the
rt_xout array by using this MATLAB command
[a,b,c,d] = model([],[],[],0)
and inspecting the variable c. The filename defaults to model.mat but can be
changed by specifying
OPTS="-DSAVEFILE=filename" in the Make command
fieldontheReal-TimeWorkshoppageoftheSimulation parameters dialog
box.
To File Block MAT-Files
Aside from the Workspace I/O MAT-file logging described above, MAT-file
logging can be done using the To File block. A separate MAT-file containing
time and input variable(s) is created for every To File block in the model. You
must specify the filename, variable name, decimation, and sample time in the
To File block’s dialog box. The To File block cannot be used in DOS real-time
targets because of limitations of the DOS target.