units_get_preferred_unit

units_get_preferred_unit returns the preferred unit for the given unit or channel name.

ssPrefUnit = units_get_preferred_unit(oUnit, ssUnit)
ssPrefUnit = units_get_preferred_unit(oUnit, ssUnit, ssChannelName)

Return Value

ssPrefUnit is the preferred unit string or an empty string if the unit is not found. If ssChannelName is specified, the preferred unit will be looked up from the channel table. If the channel is not available, the preferred unit is taken from the “Preferred” column in the units table. (see : ref: overview-units).

Parameters

oUnit

Is the unit converter object, returned by units.

ssUnit

ssUnit is one of the defined units (see Unit Converter). Can be an empty string, if the ssChannelName is given.

ssChannelName

ssChannelName is one of the channel names from the channel table (see Unit Converter).

Comment

Can also be invoked in the following form: oUnit.preferred(ssUnit, ssChannelName).

Example

u = units()
units_get_preferred_unit(u, "Hp")
kW

History

Version Description
R2013.11 New.

See also

Unit Converter, units

id-759758