File Exchange

## units.m

version 1.0.0.0 (3.51 KB) by
Converts physical unit1 into unit2.

Updated 10 Nov 2003

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

CONSISTENCY OF UNITS IS NOT CHECKED FOR!
(i.e., units(1,'m','kg') = 1, which is of course nonsense.)

### Cite As

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

Joerg Bretschneider

useful & correct for simple purposes, but not a systematic approach. SI prefixes are incomplete and not handled properly (ym for µm is puzzling, as it has its use for yocto (1e-24)). The code could be written far more compact (1000 lines reduced to 200 using simple concepts)

Anton Macicek

Saidu Waziri

Useful program

Matt Allen

Great little program with an impressive list of units stored. It's nice to have just to have all of these units listed in one place.

Mark M

This function has been useful to me. The temperature portion for the second unit needs to have the "c" changed to "x", line 648 to 659; Those "temp = size(c);" lines are also not used for anything. This error occurs only when using the temperature conversions. It is easy to fix.

Kelvin Cruz

myesha morgan

Where is the location where i can find where the acre,yard,mile,quart came from.
do you have it on this website?

Myesha Molea

well i am looking for where a acre,yard,miles,and qarts came from,do you
have it where is the location.