Unit Converters

Convert units of pressure, length, time, force, mass, accel., temp, speed, frequency, area, & more!
2.6K Downloads
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:

kPa2psi(700)

ans =

101.5264

Supported units and their abbreviations:

ACCELERATION:
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)

ANGLE:
degrees (deg)
radians (rad)

AREA:
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)

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

ENERGY AND WORK:
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)

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

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

LENGTH:
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)

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

POWER:
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)

PRESSURE:
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)

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

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

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

VOLUME:
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
Communities

Community Treasure Hunt

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

Start Hunting!

unit_converters/

Version Published Release Notes
1.24.0.0

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

1.23.0.0

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

1.22.0.0

Edited description text.

1.20.0.0

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

1.19.0.0

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

1.14.0.0

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

1.13.0.0

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

1.12.0.0

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.

1.11.0.0

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

1.10.0.0

Computing: bits and bytes.

1.8.0.0

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

1.7.0.0

Force (or weight) conversions now included.

1.6.0.0

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

1.5.0.0

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

1.4.0.0

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

1.3.0.0

Added acceleration converters, clarified documentation, added occasional commentary.

1.2.0.0

edited description text

1.0.0.0