Main Content

pm_addunit

Add new unit to unit registry

Syntax

pm_addunit(unitname, conversion, unitexpression)

Description

pm_addunit(unitname, conversion, unitexpression) introduces a new unit, unitname, defined as conversion * unitexpression.

The first argument, unitname, must be a valid unit name, that is, it must begin with a letter and contain only letters and numbers.

The second argument, conversion, may be either a positive real scalar or a 1x2 array. If this argument has two elements, then it is specifying an affine conversion, with the first element (a positive real number) being the linear conversion coefficient, and the second being the offset. For more information, see Thermal Unit Conversions.

The third argument, unitexpression, must be a valid unit expression in terms of units already defined in the unit registry.

The following operators are supported in the unit mathematical expressions:

*Multiplication
/Division
^Power
+, -Plus, minus — for exponents only
()Brackets to specify evaluation order

Examples

Add a new unit centimeter, cm, in terms of meter, m:

pm_addunit('cm', 0.01, 'm');

Add a new unit newton, N, in terms of kilograms, meters, and seconds:

pm_addunit('N', 1, 'kg*m/s^2');

Add a new unit Fahrenheit, degF, in terms of Celsius:

pm_addunit('degF', [5/9 -32*5/9], 'degC');

Version History

Introduced in R2007a