Separate units from expression
Separate the units from the expression 10*t*u.m/u.s
,
where u = symunit
, by providing two output arguments
for separateUnits
.
u = symunit; syms t speed = 10*t*u.m/u.s; [Data,Units] = separateUnits(speed)
Data = 10*t Units = 1*([m]/[s])
Return only the expression with the units removed by providing one output argument.
Data = separateUnits(speed)
Data = 10*t
When the expression has incompatible units, separateUnits
errors.
Units are incompatible when they do not have the same dimensions,
such as length or time.
Separate the units from 2*u.m + 3*u.s
, where u =
symunit
. The separateUnits
function throws an error.
Instead, to list the units in the input, use findUnits
.
u = symunit; [Data,Units] = separateUnits(2*u.m + 3*u.s)
Error using separateUnits (line 52) Argument has incompatible units.
When the input has inconsistent units that
can be converted to the same unit, then separateUnits
performs
the conversion and returns the separated result. Units are inconsistent
when they cannot be converted to each other with a conversion factor
of 1
Separate the units from 2*u.m + 30*u.cm
.
Even though the units differ, separateUnits
converts
them to the same unit and returns the separated result.
u = symunit; [Data,Units] = separateUnits(2*u.m + 30*u.cm)
Data = 230 Units = [cm]
checkUnits
| findUnits
| isUnit
| newUnit
| str2symunit
| symunit
| symunit2str
| unitConversionFactor