Log Signal Data That Uses Units
To have logged data include the units specified for signals, use theDataset
orTimeseries
logging format, which stores logging information in MATLAB®timeseries
objects.
Signal logging usesDataset
format. Output logging (Configuration Parameters>Data Import/Export>Output) usesDataset
as the default format. The default save format for theTo FileandTo Workspace块是Timeseries
.
If you useDataset
orTimeseries
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 theFormatconfiguration parameter to
Dataset
.In the Block Parameters dialog box forOutportblocks for which you want to capture units information, set theUnitparameter to match the units of the input signal.
For example, in this model theIn1
block has itsUnitparameter set tonewton
andIn2
block usesm
(meters). Open themodel. 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 signalb
.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 theTo Workspaceblock.
simout1.signal2.DataInfo.Units
ans = Units with properties: Name: 'm'
This example model shows how to view the data logged in aTime Scopeblock. Open themodel.
To use theTime Scopeblock to log data, in the scope selectConfiguration Properties>Logging>Log data to workspaceand specify a variable (ScopeData
in this example). TheIn3
block usesm
(meters). Simulate the model and then at the MATLAB command line, enter:
ScopeData.get(1).Values.DataInfo.Units
ans = Units with properties: Name: 'm'