Documentation

Log Signal Data That Uses Units

To have logged data include the units specified for signals, use theDatasetorTimeserieslogging format, which stores logging information in MATLAB®timeseriesobjects.

Signal logging usesDatasetformat. Output logging (Configuration Parameters>Data Import/Export>Output) usesDatasetas the default format. The default save format for theTo FileandTo Workspace块是Timeseries.

If you useDatasetorTimeseriesformat 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:

  1. Set theFormatconfiguration parameter toDataset.

  2. 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 theIn1block has itsUnitparameter set tonewtonandIn2block 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 forsignal1of 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 (ScopeDatain this example). TheIn3block 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'

Related Examples

More About

Was this topic helpful?