# unitsratio

Unit conversion factors

## Syntax

```ratio = unitsratio(to,from) ```

## Description

`ratio = unitsratio(to,from)` returns the number of `to` units per one `from` unit. You can specify any of the measurement units supported by the `validateLengthUnit` function, such as kilometers, or the angle units `'radians'` and `'degrees'`.

For example, using measurement units, `unitsratio('cm','m')` returns the value `100` because there are 100 centimeters per meter.

The variables `to` and `from` are case insensitive and can be either singular or plural. For example, `unitsratio` accepts any of the values listed in the following table for angle units.

Unit Name

Acceptable Values

```'rad', 'radian(s)'```

degree

```'deg', 'degree(s)'```

The `unitsratio` function makes it easy to convert values from one system of units to another. For example, if you want to convert the value `100` kilometers (`from` units) to meters (`to` units), you can use the following code:

```y = unitsratio('meters','kilometers') * 100 y = 100000```

## Examples

collapse all

Create a conversion factor for international feet to meters.

`mPerFoot = unitsratio('meter','feet')`
```mPerFoot = 0.3048 ```

Convert 100 international feet into meters.

`m = mPerFoot * 100`
```m = 30.4800 ```

Create the inverse conversion factor and multiply it by the `mPerFoot` conversion factor.

`unitsratio('feet','meter') * mPerFoot`
```ans = 1.0000 ``` 