Converts physical unit1 into unit2.


Updated 10 Nov 2003

No License

y = units(x,'unit1','unit2') - Converts x from physical unit1 to unit2

example: units(1,'in','mm') = 25.4

The following units are supported:
Acceleration: m/s^2, cm/s^2, mm/s^2, ft/s^2, in/s^2, G
Angle: rad, deg, rev
Area: km^2, m^2, cm^2, mm^2, ym^2 (square-micrometer), sq-mile, sq-yd, sq-ft, sq-in,
acres, ha, ar
Area Moment of Inertia: m^4, cm^4, mm^4, ft^4, in^4
Density: t/m^3 (metric), kg/m^3, g/cm^3, g/mm^3, lbs/ft^3 lbs/in^3, lbs/galUS, lbs/galUK
Energy, Work, Torque: GJ, MJ, kJ, J, mJ, Nm, Ncm, Nmm, kWh, Wh, Ws, lb-ft, lb-in, oz-in,Btu,
Btu, cal, kcal, eV
Force: MN, kN, N, dyne, lbf, kip
Fuel Consumption: l/100km, miles/galUS
Frequency, Angular Velocity: GHz, MHz, kHz, Hz, 1/s, 1/min, 1/h, rad/s, deg/s, rpm
Length: km, m, dm, cm, mm, ym (micrometer), nm, mile, yard, ft, in, mill,
Angstrom, light-year
Mass: t (metric), tUS, tUK, kg, g, mg, yg (microgram), ng, lbs, oz
Mass Moment of Inertia: kg*m^2, kg*cm^2, kg*mm^2, g*m^2, g*cm^2, g*mm^2, lb*ft^2, lb*in^2
Power: GW, MW, kW, W, mW, hp, Btu/h, Btu/s, kcal/h, J/h
Pressure, Stress: GPa, MPa, kPa, hPa, Pa, bar, mbar, atm, dyne/cm^2, ksi, psi, mmHg, mmH2O
Strain: m/m, mm/m, ym/m (micrometer/m), nm/m, %, o/oo, in/in, mill/in
Stress Intensity Factor: MPa*m^1/2, MPa*mm^1/2, ksi*in^1/2, psi*in^1/2
Temperature: degK, degC, degF, degR
Time: yr (365 days), mth (30 days), wk, day, hr, min, s, ms, ys (microsecond), ns
Velocity: km/s, km/h, m/s, cm/s, mm/s, m/min, mm/min, mps, mph, ft/s, in/s, ft/min,
in/min, Mach, knots
Viscosity: Ns/m^2, poise, centipoise, lbfs/sq-ft
Volume: km^3, m^3, cm^3, mm^3, ym^3, cu-mile, cu-ft, cu-in, l, cl, ml, galUS, galUK,
pint (liquid US), quart (liquid US), fl-oz (liquid US)

Metric Prefixes: Yotta, Zetta, Exa, Peta, Terra, Giga, Mega, Myria, kilo, hecto, 1
deci, centi, milli, micro, nano, pico, femto, atto, zepto, yocto

(i.e., units(1,'m','kg') = 1, which is of course nonsense.)

Cite As

Henning Ressing (2023). units.m (https://www.mathworks.com/matlabcentral/fileexchange/4093-units-m), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R10
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on Automotive in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes

- added units of strain
- fixed forgotten semicolon