UnitConvert

UnitConvert[quantity,targetunit]

attempts to convert the specified quantity to the specified targetunit.

UnitConvert[quantity]

converts the specified quantity to SI base units.

Details

  • The targetunit can be a canonical unit or a Quantity expression.
  • When targetunit is a Quantity, the resulting output will have the same unit as targetunit.
  • A targetunit specification can also be one of the following unit systems: "SIBase", "SI", "Imperial", or "Metric".
  • UnitConvert accepts TimeSeries, EventSeries, and TemporalData inputs and attempts to convert Quantity values to the specified targetunit.
  • UnitConvert accepts Association inputs and attempts to convert Quantity values to the specified targetunit.
  • An internet connection is required for conversion between currency units.

Examples

open allclose all

Basic Examples  (3)

Convert from miles to kilometers:

Convert a Quantity object to the appropriate SI base units:

Convert the speed of light to SI base units:

Scope  (8)

UnitConvert operates on lists of Quantity expressions:

Convert Quantity expressions to their equivalent SI units:

Get the SI unit value of a physical constant:

Convert the values of a time series:

Convert the Quantity values of an association to SI base units:

Convert the unit of a QuantityDistribution expression:

UnitConvert accepts structured arrays like QuantityArray or SymmetrizedArray objects:

UnitConvert accepts Association specifications:

Applications  (4)

Use UnitConvert to examine the value of a unit in the "SIBase" unit system:

Use UnitConvert to find the value of a unit derived from SI base units:

Find the range of masses in kilograms for different objects, from the universe to an electron:

Find the volume of different bottles of wines:

Properties & Relations  (9)

The first argument of UnitConvert can be given as a unit string:

The targetunit specification can be a product or quotient of strings:

An independent unit can only be converted to itself and multiples or submultiples of itself:

The second argument of UnitConvert can be a MixedUnit specification:

The units given in a MixedUnit specification do not need to be ordered:

UnitConvert can convert mixed Quantity objects:

UnitConvert will automatically attempt to interpret an unknown unit string:

When the target unit is specified as a Quantity object, its magnitude will be ignored:

The "SIBase" unit for "InformationUnit" is "Bits":

The "SIBase" unit for "MoneyUnit" is "USDollars":

UnitConvert threads over lists:

Possible Issues  (3)

UnitConvert will return $Failed for incompatible specifications, such as those between different unit dimensions:

Conversion to a unit system will return a unit that exists in that unit system, not necessarily the base unit of that system:

UnitConvert[q,"SIBase"] typically converts all units to their SI base units:

For special cases where no SI unit is standard for the dimension, non-SI units are permitted in SI base form:

Introduced in 2012
 (9.0)