Main Content

baseUnits

Base units of unit system

Description

example

baseUnits(unitSystem) returns the base units of the unit system unitSystem as a vector of symbolic units. You can use the returned units to create new unit systems by using newUnitSystem.

Examples

collapse all

Get the base units of a unit system by using baseUnits. Then, modify the base units and create a new unit system using the modified base units. Available unit systems include SI, CGS, and US. For all unit systems, see Unit Systems List.

Get the base units of the SI unit system.

SIUnits = baseUnits('SI')
SIUnits =
[ [kg], [s], [m], [A], [cd], [mol], [K]]

Note

Do not define a variable called baseUnits because the variable will prevent access to the baseUnits function.

Define base units that use kilometer for length and hour for time by modifying SIUnits using subs.

u = symunit;
newUnits = subs(SIUnits,[u.m u.s],[u.km u.hr])
newUnits =
[ [kg], [h], [km], [A], [cd], [mol], [K]]

Define the new unit system by using newUnitSystem.

newUnitSystem('SI_km_hr',newUnits)
ans = 
    "SI_km_hr"

To convert units between unit systems, see Unit Conversions and Unit Systems.

Input Arguments

collapse all

Name of the unit system, specified as a string or character vector.

Version History

Introduced in R2017b