Contenuto principale

convertUnits

R2026b

Convert units of Simulink.sdi.Signal object

Description

convertUnits(sig,units) converts the stored units of the Simulink.sdi.Signal object sig to the units specified by units. When you convert the stored units, the software also updates the display units. For a list of supported units, see Allowed Units. The convertUnits function converts the units of Simulink.sdi.Signal objects that contain data of all built-in and fixed-point types.

Changing the stored units of a Signal object does not affect the model that created the signal. Subsequent simulations of the model log data using the original units.

Note

Unit conversion does not support undo and may lead to precision loss.

example

Examples

collapse all

Convert signal units from meters per second to miles per hour.

Display the stored units and the displayed units of the Simulink.sdi.Signal object mySig.

mySig.StoredUnits
ans = 'm/s'
mySig.DisplayUnits
ans = 'm/s'

Convert the signal units to miles per hour. When you convert the stored units, the software also updates the display units.

convertUnits(mySig,"mph")
mySig.StoredUnits
ans = 'mph'
mySig.DisplayUnits
ans = 'mph'

Input Arguments

collapse all

Signal with units to convert, specified as a Simulink.sdi.Signal object.

Desired signal units, specified as a string or character vector. For a list of accepted units, see Allowed Units.

Example: "m"

Version History

Introduced in R2018a