Unit Converters

Convert units of pressure, length, time, force, mass, accel., temp, speed, frequency, area, & more!
Updated 6 Aug 2014

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

Intuitive functions for conversion of acceleration, angle, area, computing, force, frequency, energy, length, mass, power, pressure, speed, temperature, time, or volume. All converters in this bundle take the form from2to().
EXAMPLE: Convert 700 kilopascals to pounds per square inch:


ans =


Supported units and their abbreviations:

centimeters per second squared (cmps2)
Earth gravities (G)
feet per second squared (ftps2)
galileos (Gal)
microgalileos (uGal)
milligalileos (mGal)
meters per second squared (mps2)
millimeters per second squared (mmps2)
nanometers per second squared (nmps2)

degrees (deg)
radians (rad)

acres (acre)
hectares (ha)
square centimeters (cm2)
square feet (ft2)
square inches (in2)
square kilometers (km2)
square meters (m2)
square miles (mi2)
square millimeters (mm2)
square yards (yd2)

bits (bit)
bytes (B)
exabytes (EB)
gigabytes (GB)
kilobytes (KB)
megabytes (MB)
petabytes (PB)
terabytes (TB)

British thermal units (Btu)
calories (cal)
electron volts (eV)
ergs (erg)
foot-pounds (ftlb)
joules (J)
kilocalories or nutritional calories (kcal)
kilojoules (kJ)
kilowatt-hours (kWh)
newton-meters (Nm)

dynes (dyn)
kilopounds (kip)
kilonewtons (kN)
pounds (lbf)
newtons (N)
ounces-force (ozf)

gigahertz (GHz)
hertz (Hz)
kilohertz (kHz)
megahertz (MHz)
radians per second (radps)
revolutions per minute (rpm)
terahertz (THz)

angstroms (A)
astronomical units (au)
centimeters (cm)
decimeters (dm)
feet (ft)
inches (in)
kilometers (km)
light years (ly)
meters (m)
micrometers or microns (um)
miles (mi)
millimeters (mm)
nautical miles (nautmi)
nanometers (nm)
picometers (pm)
yards (yd)

atomic mass units (amu)
grams (g)
kilograms (kg)
pounds-mass (lbm)
microgram (ug)
milligrams (mg)
slugs (slug)

boiler horsepower (hpb)
British thermal units per hour (Btuph)
electrical horsepower (hpe)
gigawatts (GW)
kilowatts (kW)
mechanical horsepower (hp)
megawatts (MW)
terawatts (TW)
watts (W)

standard atmospheres (atm)
bar (bar)
dynes per square centimeter (dynpcm2)
feet of water column at 4°C (ftH2O)
hectopascals (hPa)
inches of water column at 4°C (inH2O)
megapascals (MPa)
kilopascals (kPa)
millibar (mbar)
millimeters of mercury at 0°C (mmHg)
pascals (Pa)
pounds per square inch (psi)
torr (Torr)

feet per second (ftps)
kilometers per hour (kmph)
knots (knot)
mach number at STP (mach)
miles per hour (mph)
meters per second (mps)

celsius (C)
fahrenheit (F)
kelvin (K)
rankine (R)

days (day)
hours (hr)
microseconds (us)
minutes (min)
milliseconds (ms)
nanoseconds (ns)
seconds (s)
years (yr)

centiliters (cl)
cubic centimeters (cc or cm3)
cubic feet (ft3)
cubic inches (in3)
cubic kilometers (km3)
cubic meters (m3)
cubic miles (mi3)
cubic yards (yd3)
liters (l)
milliliters (ml)
US liquid gallons (gal)
US liquid ounces (oz)
US liquid quarts (qt)

Convert units, organize your code, and a year from now when you look over your old scripts, instantly recognize what units are associated with variables, before and after conversion. Other converters are available (acknowledged below), but the functions in this bundle were designed to be simpler, more comprehensive, and more intuitive. Please alert me if you find any errors.

Cite As

Chad Greene (2024). Unit Converters (https://www.mathworks.com/matlabcentral/fileexchange/35258-unit-converters), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2010a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!


Version Published Release Notes

Fixed a typo in cm32l--thanks for catching the error, Maximilian.

Now with more significant digits. Thanks for the suggestions Erich.

Edited description text.

Most powerful version to date! Now with hp, Btuph, W, kW, MW, GW, TW, hpe, and hpb!

The most powerful version to date! W, hp, hpe, hpb, kW, MW, GW, TW, Btuph.

A lot of energy went into making this update: Btu, cal, kcal, eV, erg, ftlb, Nm, J, kJ, kWh.

Turned up the volume in this release. cl, cc, ml, cm3, ft3, in3, km3, m3, mi3, gal, l, oz, qt, yd3.

Acceleration and gravity: Gal, mGal, uGal, nmps2, mps2, cmps2, G, ftps2, mmps2. Note that in this release, nms2 has become nmps2 for consistency with naming convention.

Area: acre, ha, cm2, ft2, in2, km2, m2, mi2, mm2, yd2.

Computing: bits and bytes.

Pressure conversions: bar, mbar, psi, hPa, Pa, kPa, MPa, ftH2O, inH2O, mmHg, Torr, atm, dynpcm2.

Force (or weight) conversions now included.

Massive addition to the bundle. Added mass conversions, mostly.

Added conversions for time, frequency, and speed. Still plenty more to come.

Now, with angstroms! Added many more length converter functions in this update. More to come soon!

Added acceleration converters, clarified documentation, added occasional commentary.

edited description text