Documentation

unit

Units of measurement

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

unit::n

Description

unit::n represents the unit of measurement n, where n follows commonly used names. For example, the units unit::m, unit::meter, and unit::metre all represent the physical unit meter. These unit objects are domain objects of domain type unit. You can use these units in arithmetical expressions as symbolic identifiers. For example, 3*unit::m^2. You must use units consistently in expressions, and you must specify units for unknown variables so that the variables themselves are dimensionless. For details, see Example 3.

Expressions containing units are not combined or simplified automatically. Use simplify or Simplify to simplify expressions containing units. Use unit::convert to convert between units.

For a list of all implemented units, see List of Units.

Examples

Example 1

Create an expression using different units of length. The common names of units work as expected.

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

Because MuPAD® does not simplify this expression automatically, use the simplify function to simplify the expression.

simplify(%)

Simplify an expression involving several different units.

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

Example 2

Convert between any two units using unit::convert.

Convert ounce to kilograms. unit::convert returns an exact conversion. Use float to obtain a floating-point result.

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

float(%)

Use unit::convert to convert between units that are not of the same type. For example, convert Newton-meter, which is a unit of torque, to Watts, which is a unit of power.

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

Rewrite the target unit, Newton-meter, in terms of a composite expression in grams, centimeters, and milliseconds.

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

Try to convert kg inch2/mm to cm. unit::convert has no effect on units it cannot convert.

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

Example 3

For numerical computations, explicitly specify units such that the variables themselves are dimensionless. If you apply units inconsistently, you might not get the desired result.

Demonstrate this issue by omitting the unit for an unknown variable in an expression. Substitute for the variable with a number and evaluate the expression using float. The float function cannot evaluate the expression.

L := 1*unit::m:
y := 0.1*unit::m:
f := y - x*cos(L/x):
float(subs(f, x = 1/PI))

Evaluate the expression by specifying units consistently. Now, the unknown variable x is dimensionless.

f := y - x*unit::m*cos(L/(x*unit::m)):
float(subs(f, x = 1/PI))

Example 4

Add new units using unit::newUnit.

Add a velocity unit to the unit domain.

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

You can use the unit unit::SpeedOfLight like any other unit. Use unit::SpeedofLight to define another velocity unit.

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

Convert 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)

Example 5

Use the conversion methods to convert between different systems of units.

Use unit::convert2SIunits to convert a mass expressed in non-metric units to SI units.

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

unit::convert2SIunits(mass)

delete mass:

Convert a temperature of 20 degrees Celsius into the Fahrenheit temperature scale using unit::Celsius2Fahrenheit.

unit::Celsius2Fahrenheit(20)

Example 6

You can use most functions such as diff, factor, and normal with unit. These functions treat units like ordinary symbolic identifiers.

Use diff, factor, and normal with unit.

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

n

The name of the physical unit. Expand the following list for all implemented units. You can represent a unit by multiple names. For example, you can represent a meter by unit::m, unit::meter, and unit::metre.

List of Units

expand all

Length

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

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

  • nm (= nanometer)

  • My (= micron = micrometer)

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

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

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

  • pt (= point), inch

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

  • yd (= yard), mile, nmile, inm (= INM)

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

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

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

Mass

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

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

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

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

  • oz (= ounce)

  • lb (= pound), 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

Time

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

  • mcsec (= mcsecond = microsec = microsecond)

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

  • s (= sec = second), das, hs, ks

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

  • h (= hour), d (= day)

  • week, month

  • year

Temperature

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

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

Plain Angle

  • degree , 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)

Velocity

  • knot, knot_UK, mach

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

  • 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, 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)

  • 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)

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

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

Ionizing Dosage

  • R (= Roentgen)

Lens Power

  • dpt (= diopter = dioptre)

Mass Per Length

  • tex, den (= denier)

Methods

expand all

convert — Convert between units

unit::convert(x, targetunit) converts all units in the arithmetical expression x to the targetunit if possible. The targetunit can be a unit (such as unit::m) or an arithmetical expression (such as unit::km/unit::s). In the second case, convert rewrites x in terms of the units found in targetunit. See Example 2.

convert2SIunits — Rewrite to SI units

unit::convert2SIunits(x) rewrites all units in the arithmetical expression x in terms of corresponding SI base units. See Example 5.

display — Format for output

unit::display(x) formats the displayed 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

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

newUnit — Define a new unit

unit::newUnit(newname = f*oldunit) creates a unit addressed by unit::newname. The name newname must be an identifier. The new unit is declared as a multiple f of one or more pre-existing units oldunit, where f is a number. See Example 4.

simplify — Combine units of the same type

unit::simplify(x) combines all units of the same type in the arithmetical expression x to one unit of that type found in x. See Example 1.

The following methods convert a numeric temperature value to the same temperature in another temperature scale. The name of a method describes the temperature scales that the method converts between. For example, Celsius2Fahrenheit converts a temperature in Celsius to the same temperature in Fahrenheit. See Example 5.

  • Celsius2Fahrenheit

  • Celsius2Kelvin

  • Celsius2Rankine

  • Celsius2Reaumur

  • Fahrenheit2Celsius

  • Fahrenheit2Kelvin

  • Fahrenheit2Rankine

  • Fahrenheit2Reaumur

  • Kelvin2Fahrenheit

  • Kelvin2Celsius

  • Kelvin2Rankine

  • Kelvin2Reaumur

  • Rankine2Fahrenheit

  • Rankine2Kelvin

  • Rankine2Celsius

  • Rankine2Reaumur

  • Reaumur2Fahrenheit

  • Reaumur2Kelvin

  • Reaumur2Rankine

  • Reaumur2Celsius

See Also

MuPAD Functions

External Websites

Was this topic helpful?