Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

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, Fh, in terms of Celsius:

pm_addunit('Fh', [5/9 -32*5/9], 'C');

Introduced in R2007a

Was this topic helpful?