## units

Extensive unit conversion package for MATLAB

Click here to download.

### Description

As the name implies, this is a fairly large unit conversion package for MATLAB. Usage is relatively simple; a string is given as input, and a value is returned. The output value corresponds to the input string converted into the reference units. Consider the following example.

>> mks('km')

ans =

1000

>> cgs('km')

ans =

100000

This means that 1 kilometer refers is the same as 1000 meters or 100000 centimeters. However, this package can also be used to convert into arbitrary units by just dividing the results. The following example shows two ways to convert one mile to feet.

>> mks('mi') / mks('ft')

ans =

5280

>> fss('mi')

ans =

5280

That explains basic usage. However, it should be noted that this particular unit conversion package allows you to use completely wild units. The following example demonstrates one of my favorite units of speed.

>> mks('furlong/fortnight')/mks('mph')

ans =

3.7202e-04

Here is an area definition you might not have known.

>> mks('furlong^2/acre')

ans =

10

Both ^ and ** are acceptable for exponents, and both (space) and * are acceptable ways to denote multiplication. The program also looks for standard SI prefixes—even on units that normally would not accept them.

>> mks('c') / mks('ft/ns')

ans =

0.9836

>> mks('Mbtu / myr') / mks('kW')

ans =

33.4111

The first of those examples shows the quirky approximation of the speed of light as about 1 foot per nanosecond, and the second example? Apparently there are about 33 kilowatts in one mega-British-thermal-unit per milliyear. These demonstrate the capabilities of this program, but it's probably most useful as a quick conversion of silly imperial units like pound or slug without having to think about it.