Define unit system
Define New Unit System from Existing System
A unit system is a collection of units to express quantities.
The easiest way to define a new unit system is to modify a default unit system,
SI to use kilometer for length and hour for time
by getting the base units using
baseunits and modifying
them by using
u = symunit; SIUnits = baseUnits('SI')
SIUnits = [ [kg], [s], [m], [A], [cd], [mol], [K]]
newUnits = subs(SIUnits,[u.m u.s],[u.km u.hr])
newUnits = [ [kg], [h], [km], [A], [cd], [mol], [K]]
Do not define a variable called
the variable will prevent access to the
Define the new unit system
SI_km_hr using the new base
ans = "SI_km_hr"
Rewrite 5 meter/second to the
SI_km_hr unit system. As
expected, the result is in terms of kilometers and hours.
ans = 18*([km]/[h])
Specify Base and Derived Units Directly
Specify a new unit system by specifying the base and derived units directly. A unit system has up to 7 base units. For details, see Unit System.
Define a new unit system with these base units: gram, hour, meter, ampere, candela, mol, and celsius. Specify these derived units: kilowatt, newton, and volt.
u = symunit; sysName = 'myUnitSystem'; bunits = [u.g u.hr u.m u.A u.cd u.mol u.Celsius]; dunits = [u.kW u.N u.V]; newUnitSystem(sysName,bunits,dunits)
ans = "myUnitSystem"
Rewrite 2000 Watts to the new system. By default,
rewrite uses base units, which can be hard to
ans = 93312000000000000*(([g]*[m]^2)/[h]^3)
Instead, for readability, rewrite 2000 Watts to derived units of
'Derived' as the third argument. Converting to
the derived units of a unit system attempts to select convenient units. The
result uses the derived unit, kilowatt, instead of base units. For more
information, see Unit Conversions and Unit Systems.
ans = 2*[kW]
name — Name of unit system
string | character vector
Name of unit system, specified as a string or character vector.
baseUnits — Base units of unit system
vector of symbolic units
Base units of unit system, specified as a vector of symbolic units. The base units must be independent in terms of the dimensions mass, time, length, electric current, luminous intensity, amount of substance, and temperature. Thus, in a unit system, there are up to 7 base units.
derivedUnits — Derived units of unit system
vector of symbolic units
Derived units of unit system, specified as a vector of symbolic units. Derived units are optional and added for convenience of representation.
A unit system is a collection of base units and derived units that follows these rules:
Base units must be independent in terms of the dimensions mass, time, length, electric current, luminous intensity, amount of substance, and temperature. Therefore, a unit system has up to 7 base units. As long as the independence is satisfied, any unit can be a base unit, including units such as newton or watt.
A unit system can have less than 7 base units. For example, mechanical systems need base units only for the dimensions length, mass, and time.
Derived units in a unit system must have a representation in terms of the products of powers of the base units for that system. Unlike base units, derived units do not have to be independent.
Derived units are optional and added for convenience of representation. For example, kg m/s2 is abbreviated by newton.
An example of a unit system is the SI unit system, which has 7 base units: kilogram, second, meter, ampere, candela, mol, and kelvin. There are 22 derived units found by calling