To have logged data include the units specified for signals, use the
Dataset
or Timeseries
logging format, which stores
logging information in MATLAB®
timeseries
objects.
Signal logging uses Dataset
format. Output logging (Configuration Parameters > Data Import/Export > Output) uses Dataset
as the default format. The default save format
for the To File and To Workspace blocks is
Timeseries
.
If you use Dataset
or Timeseries
format for
signal logging or for To File block or To Workspace block logging, the logged data includes
units information.
To capture units information for output logging:
Set the Format configuration parameter to
Dataset
.
In the Block Parameters dialog box for Outport blocks for which you want to capture units information, set the Unit parameter to match the units of the input signal.
For example, in this model the In1
block has its
Unit parameter set to newton
and
In2
block uses m
(meters). Open the model. After you simulate the model, you can see the units for the logged
data.
You can view the units in the signal logging data for signal1
of
the bus signal b
.
logsout.get('a').Values.signal1.DataInfo
tsdata.datametadata Package: tsdata Common Properties: Units: newton (Simulink.SimulationData.Unit) Interpolation: linear (tsdata.interpolation)
You can view the units in the data logged in the To Workspace block.
simout1.signal2.DataInfo.Units
ans = Units with properties: Name: 'm'
This example model shows how to view the data logged in a Time Scope block. Open the model.
To use the Time Scope block to log data, in the scope select Configuration Properties > Logging > Log data to workspace and specify a variable (ScopeData
in this example). The
In3
block uses m
(meters). Simulate the model and then
at the MATLAB command line, enter:
ScopeData.get(1).Values.DataInfo.Units
ans = Units with properties: Name: 'm'