Documentation Center

  • Trial Software
  • Product Updates

unit

Physical units

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

unit::nam

Description

Objects such as unit::m, unit::kg, unit::sec etc. represent the physical units "meters", "kilograms", "seconds" etc.

unit domain provides some methods for simplifying and converting arithmetical expressions involving such units.

unit objects such as unit::m or unit::kg serve for representing physical units. They are domain objects of domain type unit.

These objects behave like symbolic names (identifiers) and can be used to build arithmetical expressions involving numbers and symbols such as 3*unit::m^2 or a*unit::cm + b*unit::inch^2/unit::mm.

Expressions such as 20*unit::cm + 0.3*unit::m involving several units of the same type (‘length,' ‘mass,' ‘time' etc.) are not simplified automatically. Use unit::convert, unit::simplify, simplify, or Simplify to convert all subexpressions to common units. These routines are described further down below.

On input, use the prefix unit:: as in unit::mm, unit::km for millimeters, kilometers etc. On the screen, this prefix is stripped off. For example, 1.23*unit::mm is displayed as 1.23 mm.

The available units are listed further down below.

Note that some units such as unit::mm, unit::millimeter and unit::millimeters represent the same physical unit. Use an interactive command such as info(unit::oz) to find information on unit::oz including all the alternative names that can be used in MuPAD®. Cf. Example 6.

    Note:   Beware: If you mix different MuPAD units representing the same physical unit, no automatic simplifications are done! Use simplify to simplify an expression such as 2*unit::m + 3*unit::meter to 5*unit::m.

Expressions such as unit::kg*(unit::m/unit::s)^2 can be used to represent a composite unit. You can convert them to other units such as unit::Joule via unit::convert.

Some of the conversion factors between the various units are given by exact rational numbers (e.g., unit::inch = 127/50*unit::cm), while others are linked by floating-point factors (e.g., unit::cal = 4.1868*unit::Joule). Use float to approximate exact values by floats. Use numeric::rationalize to approximate floats by rational numbers.

Most system functions such as diff, factor, normal etc. accept expressions containing units, treating the units like symbolic identifiers. See Example 8.

The available units are listed below. If the required unit is not available, you can use unit::newUnit to add your own unit to the unit domain. See Example 3.

Length:

  • am, f (= Fermi = fermi), XU (= Xu = xu = XE), pm

  • Ao (= Angstroem = angstroem = Angstrom = angstrom)

  • nm (= nanometer = nanometers)

  • My (= micron = microns = micrometer = micrometers)

  • mm (= millimeter = millimeters), cm (= centimeter = centimeters)

  • dm (= decimeter = decimeters), m (= meter = meters)

  • dam, hm, km (= kilometer = kilometers), Mm, Gm, Tm, Pm, Em

  • pt (= point = points), inch (= inches = zoll = Zoll)

  • ft (= foot = feet), ft_US (= foot_US = feet_US)

  • yd (= yard = yards = Elle = Ellen), mile (= miles), nmile, inm (= INM)

  • AU (= AE), ly (= lightyear = lightyears = Lj = lj), pc (= parsec)

  • ch, fm (= fathom = fathoms), fur (= furlong = furlongs), gg, hand

  • li (= link = links), line, mil, rod (= perch = pole), span

Mass:

  • ag, fg, pg, ng, mcg (= mcgram = mcgrams = microgram = micrograms)

  • mg (= milligram = milligrams), cg, dg, g (= gram = grams), hg

  • kg (= kilogram = kilograms), Mg, Gg, Tg, Pg, Eg

  • t, kt, Mt, ct (= carat = Kt = Karat = karat)

  • oz (= ounce = ounces = Unze = Unzen = unze = unzen)

  • lb (= pound = pounds), stone, cwt (= sh_cwt)

  • cwt_UK (= long_cwt = gross_cwt), tn (= ton = short_ton), ton_UK

  • long_ton (= gross_ton), slug, gr, dr, quarter, cental

  • Pfd (= Pfund = pfund), Ztr (= Zentner = zentner)

  • dz (= Doppelzentner = doppelzentner)

Time:

  • as, fs, ps, ns (= nsec = nanosec = nanosecond = nanoseconds)

  • mcsec (= mcsecond = mcseconds = microsec = microsecond = microseconds)

  • ms (= msec = millisec = millisecond = milliseconds), cs, ds

  • s (= sec = second = seconds = Sekunde = Sekunden), das, hs, ks

  • Ms, Gs, Ts, Es, Ps, min (= minute = minutes = Minute = Minuten)

  • h (= hour = hours = Stunde = Stunden), d (= day = days = Tag = Tage)

  • week (= weeks = Woche = Wochen), month (= months = Monat = Monate)

  • year (= years = Jahr = Jahre)

Temperature:

  • K (= kelvin = Kelvin), Fahrenheit (= fahrenheit), Celsius (= celsius)

  • Rankine (= rankine), Reaumur (= reaumur)

Plain Angle:

  • degree (= degrees), rad (= radian)

Solid Angle:

  • sr (= steradian)

Data Size, Storage Capacity:

  • bit (= Bit) kbit (= kBit), Mbit (= MBit), Gbit (= GBit), Tbit (= TBit)

  • byte (= Byte), kbyte (= kByte), Mbyte (= MByte), Gbyte (= GByte)

  • Tbyte (= TByte)

Data Rate (Bits per Second):

  • bps

Signal Rate (= Frequency):

  • Bd (= Baud = baud)

Velocity:

  • knot, knot_UK, mach

Acceleration:

  • Gal, gn

Force:

  • aN, fN, nN, pN, mcN, mN, cN, dN, N (= Newton = newton), daN, hN, kN, MN, GN

  • TN, PN, EN, p (= pond = Pond), kp (= kilopond = Kilopond), dyn, pdl, lbf

  • ozf, tonf

Torque (= Energy):

  • aNm, fNm, pNm, nNm, mcNm, mNm, cNm, dNm, Nm (= Newtonmeter = newtonmeter)

  • daNm, hNm, kNm, MNm, GNm, TNm, PNm, ENm, kpm

Angular Momentum:

  • aNms, fNms, pNms, nNms, mcNms, mNms, cNms, dNms

  • Nms (= Newtonmetersec = newtonmetersec)

  • daNms, hNms, kNms, MNms, GNms, PNms, ENms, TNms

Energy, Work:

  • aJ (= aWs), fJ (= fWs), pJ (= pWs), nJ (= nWs), mcJ (= mcWs = microWs)

  • mJ (= mJoule = mjoule = mWs), cJ (= cWs), dJ (= dWs)

  • J (= Joule = joule = Ws), daJ (= daWs), hJ (= hWs)

  • kJ (= kJoule = kjoule = kWs), MJ (= MJoule = Mjoule = MWs)

  • GJ (= GWs), TJ (= TWs), PJ (= PWs), EJ (= EWs), Wh, kWh, MWh, GWh

  • cal (= Calory = calory), kcal, aeV, feV, peV, neV, mceV, meV, ceV, deV, eV

  • daeV, heV, keV, MeV, GeV, TeV, PeV, EeV, PSh, erg, Btu, therm

Power:

  • aW, fW, pW, nW, mcW (= mcWatt = mcwatt = microW = microWatt = microwatt)

  • mW (= mWatt = mwatt), cW, dW, W (= Watt = watt), daW, hW

  • kW (= kWatt = kwatt), MW (= MWatt = Mwatt), GW (= GWatt = Gwatt)

  • TW, PW, EW, PS, hp (= bhp)

Frequency:

  • aHz, fHz, pHz, nHz, mcHz, mHz, cHz, dHz, Hz (= Hertz = hertz), daHz, hHz

  • kHz (= kHertz = khertz), MHz (= MHertz = Mhertz)

  • GHz (= GHertz = Ghertz), THz, PHz, EHz

Pressure, Stress:

  • aPa, fPa, pPa, nPa, mcPa, mPa, cPa, dPa, Pa (= Pascal = pascal)

  • daPa, hPa (= hPascal = hpascal), kPa, MPa, GPa, TPa, PPa, EPa

  • mcbar (= mcBar = microbar = microBar), mbar (= mBar), bar (= Bar)

  • kbar (= kBar), at (= ata = atu), atm, mmH2O (= mmWS), mH2O (= mWS)

  • inH2O, ftH2O, mmHg, mHg, inHg, psi, Torr

Area:

  • a (= are = Ar), ac (= acre), b (= barn), ha (= hectare = Hektar)

  • ro (= rood), township, circ_mil, circ_inch

Volume:

  • al, fl, pl, nl, mcl, ml, cl, dl, l (= Liter = liter = Litre = litre), dal

  • hl, kl, Ml, Gl, Tl, Pl, El, gal (= gallon), gal_UK, barrel, bu_UK, chaldron

  • pottle, pint_UK, pk_UK, qt_UK, gill, gill_UK, floz, floz_UK, fldr, fldr_UK

  • minim, minim_UK, liq_qt, liq_pt, dry_bu, dry_pk, bbl, dry_gal, dry_qt, dry_pt

European Currency:

  • cent (= Cent), EUR (= EURO = Euro), ATS, DEM (= DM), BEF, ESP, FIM, FRF, LUF

  • NLG, PTE, IEP, ITL

Molecular Substance:

  • fmol, amol, pmol, nmol, mcmol (= mcMol = micromol = microMol)

  • mmol (= mMol), cmol, dmol, mol (= Mol), damol, hmol, kmol (= kMol), Mmol

  • Gmol, Tmol, Pmol, Emol

Electric Current, Amperage:

  • aA, fA, pA, nA (= nAmpere = nampere)

  • mcA (= microA = microAmpere = microampere), mA (= mAmpere = mampere)

  • cA, dA, A (= ampere = Ampere), daA, hA, kA (= kAmpere = kampere), MA, GA

  • TA, PA, EA, Bi (= Biot = biot), Gb (= Gilbert = gilbert)

Electric Voltage:

  • aV, fV, pV, nV (= nanoV = nVolt = nvolt)

  • mcV (= microV = mcVolt = mcvolt), mV (= mVolt = mvolt), cV, dV

  • V (= Volt = volt), daV, hV

  • kV (= kVolt = kvolt)

  • MV (= MVolt = Mvolt), GV (= GVolt = Gvolt), TV, PV, EV

Electric Resistance:

  • aOhm (= aohm), fOhm (= fohm), pOhm (= pohm), nOhm (= nohm)

  • mcOhm (=mcohm = microOhm = microohm)

  • mOhm (= mohm = milliOhm = milliohm), dOhm (= dohm), cOhm (= cohm)

  • Ohm (= ohm), daOhm (= daohm), hOhm (= hohm), kOhm (= kohm), MOhm (= Mohm)

  • GOhm (= Gohm), TOhm (= Tohm), POhm (= Pohm), EOhm (= Eohm)

Electric Charge:

  • aC, fC, pC, nC, mcC, mC, cC, dC, C (= Coulomb = coulomb), daC, hC, kC, MC, GC, TC

  • PC, EC

Electric Capacity:

  • aF, fF, pF (= pFarad = pfarad), nF (= nFarad = nfarad)

  • mcF (= mcFarad = mcfarad = microF = microFarad = microfarad)

  • mF (= mFarad = mfarad), cF, dF, F (= Farad = farad), daF, hF

  • kF (= kFarad = kfarad) , MF, GF, TF, PF, EF

Electric Conductance:

  • S (= Siemens = siemens)

Magnetic Inductance:

  • H (= Henry = henry)

Magnetic Flux Density, Magnetic Inductivity:

  • T (= Tesla = tesla), G (= Gauss = gauss)

Magnetic Flux:

  • Wb (= Weber = weber), M (= Maxwell = maxwell)

Magnetic Field Strength:

  • Oe (= Oersted = oersted)

Magnetomotive Force (= Electric Current):

  • Gb (= Gilbert = gilbert)

Luminous Intensity:

  • fcd, acd, pcd, ncd, mccd, mcd, ccd, dcd, cd (= candela = Candela), dacd, hcd

  • kcd, Mcd, Gcd, Tcd, Pcd, Ecd, HK, IK

Luminance:

  • sb (= stilb), asb (= apostilb)

Luminous Flux:

  • lm (= lumen)

Illuminance:

  • lx (= lux), ph (= phot), nx

Radiation:

  • langley

Radioactivity:

  • aBq, fBq, pBq, nBq, mcBq, mBq, cBq, dBq, Bq (= Becquerel = becquerel), daBq

  • hBq, kBq, MBq, GBq, TBq, PBq, EBq, Ci (= Curie)

Equivalent Dosage:

  • aSv, fSv, pSv, nSv, mcSv, mSv, cSv, dSv

  • Sv (= Sievert = sievert), daSv, hSv, kSv, MSv, GSv, TSv, PSv, ESv

  • arem, frem, prem, nrem, mcrem, mrem, crem, drem

  • rem (= Rem), darem, hrem, krem, Mrem, Grem, Trem, Prem, Erem

Absorbed Dosage:

  • aGy,fGy,pGy,nGy,mcGy,mGy,cGy,dGy, Gy (= Gray = gray), daGy,hGy,kGy, MGy, GGy

  • TGy,PGy,EGy, rd

Ionising Dosage:

  • R (= Roentgen)

Lens Power:

  • dpt (= diopter = dioptre)

Dynamic Viscosity:

  • P (= Poise)

Kinematic Viscosity:

  • St (= Stokes)

Mass Per Length:

  • tex, den (= denier)

Examples

Example 1

Units not convertible are left alone by unit::convert:

unit::convert(1.23*unit::kg*unit::inch^2/unit::mm, unit::cm)

unit::convert(unit::km/unit::hour, unit::m/unit::sec)

Example 2

unit::simplify favors kg over pounds:

unit::simplify(1.23*unit::kg^2/unit::pound*unit::inch^2/unit::mm)

Example 3

We add new velocity units to the unit domain:

unit::newUnit(SpeedOfLight = 300000*unit::km/unit::sec)

Now, the unit unit::SpeedOfLight exists and can be used like any other unit in the unit domain. We use it to define yet another velocity unit:

unit::newUnit(Warp9 = 1.516*unit::SpeedOfLight)

We convert the velocity of 123.4 miles per hour into the new speed units:

unit::convert(123.4*unit::mile/unit::hour, unit::SpeedOfLight)

unit::convert(123.4*unit::mile/unit::hour, unit::Warp9)

We verify the new units:

unit::convert(unit::SpeedOfLight, unit::km/unit::sec)

unit::convert(unit::Warp9, unit::SpeedOfLight)

unit::convert(unit::Warp9, unit::km/unit::sec)

Example 4

We create a symbolic expression involving different units of type ‘length':

27*unit::cm + 30*unit::mm

This expression is not simplified automatically. We apply simplify:

simplify(%)

We convert this length to inch:

unit::convert(%, unit::inch)

float(%)

Here is another example for simplification and conversion:

1234*unit::g + 1.234*unit::kg*unit::m^2/unit::inch^2

simplify(%)

unit::convert(%, unit::ounce)

The target unit in unit::convert may be an expression:

unit::convert(unit::pound*unit::km/unit::hour,
              unit::kg*unit::m/unit::s)

Example 5

The probably most interesting method of the unit domain is the conversion routine unit::convert. Given any expression involving units, you can specify a target unit which is to be used to express the units:

unit::convert(unit::ounce, unit::kilogram)

The target unit needs not be of the same physical type as the expression that is to be rewritten. In the following example, we wish to rewrite a torque (given in "Newton meters") in terms of units involving the power unit "Watt." Note that a torque is an energy, i.e., "power" multiplied by "time":

unit::convert(1.23*unit::Nm, unit::W)

We wish to rewrite "Newton meters" in terms of units involving "centimeters":

unit::convert(unit::Nm, unit::cm)

The target unit may be a composite expression. We wish to rewrite "Newton meters" in terms of "grams," "centimeters," and "milliseconds":

unit::convert(unit::Nm, unit::g*unit::cm^2/unit::msec^2)

Example 6

The info command provides information on units. In particular, it lists alternative names that can be used in MuPAD:

info(unit::nm)
nanometer: a length unit
Alternative names: unit::nanom, unit::nanometer, unit::nanometers, unit::nm
info(unit::Joule)
joule: a unit of energy
Alternative names: unit::J, unit::Joule, unit::Newtonmeter, unit::Nm, unit::Ws, unit::joule, unit::newtonmeter

Example 7

We use unit::convert2SIunits to convert a mass expressed in non-metric units to SI base units:

mass := 2*unit::cal*unit::msec^2/unit::inch^2 - 45*unit::carat

unit::convert2SIunits(mass)

delete mass:

Example 8

Most system functions such as diff, factor, normal etc. treat units like ordinary symbolic identifiers:

diff(x/unit::m*exp(-x^2/unit::m^2), x)

factor(%)

normal((4*unit::m^2 - a^2*unit::m^2)/(2*unit::m - a*unit::m))

Parameters

nam

The name of the physical unit, see the list below. Some units such as unit::mm and unit::millimeter represent the same physical unit.

Methods

expand all

convert — Convert an expression to other units

convert(x, targetunit) converts all units in the arithmetical expression x to multiples of the targetunit if possible. The targetunit may be one of the unit objects of type ‘length,' ‘mass' etc. It may also be an arithmetical expression such as unit::km/unit::sec. In this case, x is rewritten in terms of the units found in targetunit.

convert2SIunits — Rewrite to SI units

convert2SIunits(x) rewrites all units in the arithmetical expression x in terms of corresponding SI base units.

simplify — Combine like units in an expression

unit:: simplify(x) converts all units in the arithmetical expression x to some basic unit found in x, i.e., all length units are expressed by the same length unit, all mass units are expressed by the same mass unit, all time units are expressed by the same time unit etc.

newUnit — Define a new unit

newUnit(newname = expression)

unit::newUnit(newname = f*oldunit) creates a new unit that may be addressed by unit::newname. Its name newname must be an identifier. It is declared as the f-fold of some unit oldunit that must be an expression such as unit::mm/unit::sec involving units provided by the unit domain. The conversion factor f must be an arithmetical expression (typically, a numerical conversion factor).

display — Format for output

display(x) formats the screen output of the arithmetical expression x such that the units appear as a separate factor at the end of each term.

findUnits — Find all units in expression

findUnits(x) returns a set of all units found in the arithmetical expression x.

Celsius2Fahrenheit — Convert degrees Celsius to degrees Fahrenheit

unit::Celsius2Fahrenheit(x) converts a numerical value x representing a temperature in degrees Celsius into a numerical value representing this temperature in degrees Fahrenheit.

Celsius2Kelvin — Convert degrees Celsius to Kelvin

unit::Celsius2Kelvin(x) converts a numerical value x representing a temperature in degrees Celsius into a numerical value representing this temperature in degrees Kelvin.

Celsius2Rankine — Convert degrees Celsius to degrees Rankine

unit::Celsius2Rankine(x) converts a numerical value x representing a temperature in degrees Celsius into a numerical value representing this temperature in degrees Rankine.

Celsius2Reaumur — Convert degrees Celsius to degrees Reaumur

unit::Celsius2Reaumur(x) converts a numerical value x representing a temperature in degrees Celsius into a numerical value representing this temperature in degrees Reaumur.

Fahrenheit2Celsius — Convert degrees Fahrenheit to degrees Celsius

unit::Fahrenheit2Celsius(x) converts a numerical value x representing a temperature in degrees Fahrenheit into a numerical value representing this temperature in degrees Celsius.

Fahrenheit2Kelvin — Convert degrees Fahrenheit to Kelvin

unit::Fahrenheit2Kelvin(x) converts a numerical value x representing a temperature in degrees Fahrenheit into a numerical value representing this temperature in degrees Kelvin.

Fahrenheit2Rankine — Convert degrees Fahrenheit to degrees Rankine

unit::Fahrenheit2Rankine(x) converts a numerical value x representing a temperature in degrees Fahrenheit into a numerical value representing this temperature in degrees Rankine.

Fahrenheit2Reaumur — Convert degrees Fahrenheit to degrees Reaumur

unit::Fahrenheit2Reaumur(x) converts a numerical value x representing a temperature in degrees Fahrenheit into a numerical value representing this temperature in degrees Reaumur.

Kelvin2Fahrenheit — Convert Kelvin to degrees Fahrenheit

unit::Kelvin2Fahrenheit(x) converts a numerical value x representing a temperature in degrees Kelvin into a numerical value representing this temperature in degrees Fahrenheit.

Kelvin2Celsius — Convert Kelvin to degrees Celsius

unit::Kelvin2Celsius(x) converts a numerical value x representing a temperature in degrees Kelvin into a numerical value representing this temperature in degrees Celsius.

Kelvin2Rankine — Convert Kelvin to degrees Rankine

unit::Kelvin2Rankine(x) converts a numerical value x representing a temperature in degrees Kelvin into a numerical value representing this temperature in degrees Rankine.

Kelvin2Reaumur — Convert Kelvin to degrees Reaumur

unit::Kelvin2Reaumur(x) converts a numerical value x representing a temperature in degrees Kelvin into a numerical value representing this temperature in degrees Reaumur.

Rankine2Fahrenheit — Convert degrees Rankine to degrees Fahrenheit

unit::Rankine2Fahrenheit(x) converts a numerical value x representing a temperature in degrees Rankine into a numerical value representing this temperature in degrees Fahrenheit.

Rankine2Kelvin — Convert degrees Rankine to Kelvin

unit::Rankine2Kelvin(x) converts a numerical value x representing a temperature in degrees Rankine into a numerical value representing this temperature in degrees Kelvin.

Rankine2Celsius — Convert degrees Rankine to degrees Celsius

unit::Rankine2Celsius(x) converts a numerical value x representing a temperature in degrees Rankine into a numerical value representing this temperature in degrees Celsius.

Rankine2Reaumur — Convert degrees Rankine to degrees Reaumur

unit::Rankine2Reaumur(x) converts a numerical value x representing a temperature in degrees Rankine into a numerical value representing this temperature in degrees Reaumur.

Reaumur2Fahrenheit — Convert degrees Reaumur to degrees Fahrenheit

unit::Reaumur2Fahrenheit(x) converts a numerical value x representing a temperature in degrees Reaumur into a numerical value representing this temperature in degrees Fahrenheit.

Reaumur2Kelvin — Convert degrees Reaumur to Kelvin

unit::Reaumur2Kelvin(x) converts a numerical value x representing a temperature in degrees Reaumur into a numerical value representing this temperature in degrees Kelvin.

Reaumur2Rankine — Convert degrees Reaumur to degrees Rankine

unit::Reaumur2Rankine(x) converts a numerical value x representing a temperature in degrees Reaumur into a numerical value representing this temperature in degrees Rankine.

Reaumur2Celsius — Convert degrees Reaumur to degrees Celsius

unit::Reaumur2Celsius(x) converts a numerical value x representing a temperature in degrees Reaumur into a numerical value representing this temperature in degrees Celsius.

Was this topic helpful?