ChangeUnit (FPScript)

21.09.2021

Converts or sets the unit(s) of a data set.

Syntax

ChangeUnit(DataSet, [ Unit ], [ UnitX ] [ , UnitZ ])

 

The syntax of the ChangeUnit function consists of the following parts:

Part

Description

DataSet

The data set with the unit(s) to be set or converted.

All data structures are allowed, except list. Supported data types are 32-bit floating point, 64-bit floating point, complex 32-bit floating point, complex 64-bit floating point, calendar time und time span.

If the argument is a list, then the function is executed for each element of the list and the result is also a list.

Unit

Specifies the target unit for the data set or its Y component.

Permitted data structures are scalar value. Supported data types are string.

UnitX

Specifies the target unit for the X component of the data set.

Permitted data structures are scalar value. Supported data types are string.

UnitZ

Specifies the target unit for the Z component of the data set.

Permitted data structures are scalar value. Supported data types are string.

Remarks

If DataSet already has a unit, then the unit is converted; otherwise it is assigned. If for one of the arguments Unit, UnitX or UnitZ you specify an empty string, the corresponding unit will be removed. If you omit the argument, the corresponding unit will remain unchanged. If conversion is not possible due to mismatching SI dimensions, an error occurs. Units with an unknown SI dimension can only be set or removed, but not transformed.

Available in

FlexPro View, Basic, Professional, Developer Suite

Examples

ChangeUnit(1.4 V, "mV")

Results in 1400. mV. The unit is converted.

ChangeUnit(1.4, "mV")

Results in 1.4 mV. The unit is set.

ChangeUnit(1.4 mV, "")

Results in 1.4. The unit is removed.

ChangeUnit(2 Pi, "1")

Results in 6.283185307179586. A dimensionless unit is transformed into the unit 1.

ChangeUnit(Signal, "mV", "ms")

The Y and X units of the signal are set or converted.

ChangeUnit(Signal, , "ms")

Only the unit of the signal's X component is set or converted. The unit of the Y component remains unchanged.

See Also

ChangeUnitSymbol Function

AdjustUnit Function

Unit Manager

Quantities in FPScript

Unit Operator

Share article or send as email:

You might be interested in these articles