Main Content

Simulink.SimulationData.Unit

Container for units for simulation data

Description

Simulink.SimulationData.Unit objects store unit information for signals.

Creation

For signals with specified units, the software creates Simulink.SimulationData.Unit objects creates when you:

  • Log data in Dataset format.

  • Log data using a To Workspace block or To File block in Timeseries format.

The Simulink.SimulationData.Unit object is stored in the Units property of the timeseries, Simulink.SimulationData.Signal, or similar object used to store logging information. For example, to access the stored unit information for a Signal object named mySig, use dot notation.

mySig.Values.DataInfo.Units
ans = 

  Unit with properties:

    Name: 'm'

Description

unitsObj = Simulink.SimulationData.Unit creates an empty Simulink.SimulationData.Unit object.

unitsObj = Simulink.SimulationData.Unit(unitName) creates a Simulink.SimulationData.Unit object with the unit specified by unitName.

example

Input Arguments

expand all

Name of logging data units, specified as a character vector.

Example: 'inches'

Properties

expand all

This property is read-only.

Units name, specified as a character vector.

Object Functions

setNameSpecify name of logging data units

Examples

collapse all

Create a Simulink.SimulationData.Unit object representing inches.

inchesUnit = Simulink.SimulationData.Unit('inches');

Create a MATLAB® timeseries object and set its Units property to the Simulink.SimulationData.Unit object.

ts = timeseries(1:10);
ts.DataInfo.Units = inchesUnit
ans = 

  Units with properties:

    Name: 'inches'

Version History

Introduced in R2016a