Compute Conversion Ratio Between Units of Length

This example shows how to use the unitsratio function to create a conversion factor for many different units of length, such as microns, millimeters, inches, international feet, and U.S. survey feet. The unitsratio function also lets you convert angles between degrees and radians. For more information, see unitsratio.

Create a conversion factor for inches to centimeters and convert 4 inches into centimeters.

cmPerInch = unitsratio('cm','inch')
cmPerInch = 2.5400
cm = cmPerInch * 4
cm = 10.1600

Create the inverse conversion factor and multiply it by the cmPerInch conversion factor.

inch = unitsratio('in','centimeter') * cmPerInch
inch = 1