convert/unit_name - Maple Programming Help

# Online Help

###### All Products    Maple    MapleSim

Home : Support : Online Help : Science and Engineering : Units : Conversions : convert/unit_name

convert/unit_name

convert units to unit names

 Calling Sequence convert(u, unit_name)

Parameters

 u - expression with units

Description

 • The $\mathrm{convert}\left(u,\mathrm{unit_name}\right)$ function returns a representation of the unit part of the expression $u$ that can be easily manipulated programmatically.
 • First this procedure determines the unit of $u$. Then every unit name or symbol in this unit expression is replaced by the function call $\mathrm{Units:-UnitName}\left(\mathrm{string form of the full unit name}\right)$. The unit-free factor, if present, is ignored.
 • If there are annotations, then the base unit name (including its context, if applicable) is converted to a string; the resulting string is applied, as a function call, to the string form of the annotations.
 • The recommended way to convert units to a particular system or otherwise control the format of units is to do this before calling $\mathrm{convert}\left(\mathrm{...},\mathrm{unit_name}\right)$, using commands such as $\mathrm{combine}$ and $\mathrm{convert}$.

Examples

The unit-free factor is ignored.

Notes:

 – To enter a unit in 2-D Math input, select the unit from the appropriate Units palette. If the unit you want is not there, select $\mathrm{unit}$ and then enter the unit.
 – In Maple 2015 and later versions, the double brackets around a unit are not displayed unless you are editing the unit.
 > $\mathrm{convert}\left(45\mathrm{sin}\left(x\right)⟦\mathrm{farad}⟧,'\mathrm{unit_name}'\right)$
 ${\mathrm{Units:-UnitName}}{}\left({"farad"}\right)$ (1)

You always get the full name (farad), even if you supply only the symbol (F). Prefixes are respected.

 > $\mathrm{convert}\left(2⟦\mathrm{uF}⟧,'\mathrm{unit_name}'\right)$
 ${\mathrm{Units:-UnitName}}{}\left({"microfarad"}\right)$ (2)

Contexts or annotations are also maintained.

 > $\mathrm{convert}\left(2⟦\mathrm{mile}[\mathrm{nautical}]\left(\mathrm{radius}\right)⟧,'\mathrm{unit_name}'\right)$
 ${\mathrm{Units:-UnitName}}{}\left({"mile\left[nautical\right]"}{}\left({"radius"}\right)\right)$ (3)

In case you would prefer units to be converted to a particular system, it is best to do that before the conversion to unit names.

 > $a≔\frac{5.8⟦\mathrm{pound}⟧⟦\mathrm{ft}⟧}{{⟦s⟧}^{2}}$
 ${a}{≔}\frac{{5.8}{}⟦{\mathrm{lb}}⟧{}⟦{\mathrm{ft}}⟧}{{⟦{s}⟧}^{{2}}}$ (4)
 > $\mathrm{convert}\left(a,'\mathrm{unit_name}'\right)$
 $\frac{{\mathrm{Units:-UnitName}}{}\left({"pound"}\right){}{\mathrm{Units:-UnitName}}{}\left({"foot"}\right)}{{{\mathrm{Units:-UnitName}}{}\left({"second"}\right)}^{{2}}}$ (5)
 > $\mathrm{a1}≔\mathrm{combine}\left(a,'\mathrm{units}'\right)$
 ${\mathrm{a1}}{≔}{0.8018787354}{}⟦{N}⟧$ (6)
 > $\mathrm{convert}\left(\mathrm{a1},'\mathrm{unit_name}'\right)$
 ${\mathrm{Units:-UnitName}}{}\left({"newton"}\right)$ (7)
 > $\mathrm{a2}≔\mathrm{convert}\left(a,'\mathrm{system}','\mathrm{base}'\right)$
 ${\mathrm{a2}}{≔}{0.8018787354}{}⟦\frac{{\mathrm{kg}}{}{m}}{{{s}}^{{2}}}⟧$ (8)
 > $\mathrm{convert}\left(\mathrm{a2},'\mathrm{unit_name}'\right)$
 $\frac{{\mathrm{Units:-UnitName}}{}\left({"kilogram"}\right){}{\mathrm{Units:-UnitName}}{}\left({"meter"}\right)}{{{\mathrm{Units:-UnitName}}{}\left({"second"}\right)}^{{2}}}$ (9)

Compatibility

 • The convert/unit_name command was introduced in Maple 17.
 • For more information on Maple 17 changes, see Updates in Maple 17.

 See Also