mixedUnits
Splits a quantity into whole parts in several units.
Category: Symbolic Computations in MATLAB > Units of Measurement
Syntax
m = mixedUnits(x, units)
Expresses x as a sum over the given units, largest first.
Description
This is the familiar conversion of 3.5 h into 3 h 30 min. Each unit except the last takes the integer part of what remains, and the last takes the remainder. The terms add up exactly to the original quantity.
The same idea gives feet and inches, or degrees, minutes and seconds.
Input arguments
x- Symbolic quantity with a unit.
units- Row vector of units of the same dimension, from largest to smallest.
Output arguments
m- Row vector with one term per unit; their sum equals
x.
Example
Hours and minutes
u = symunit;
mixedUnits(3.5*u.h, [u.h u.min])
mixedUnits(5*u.ft, [u.ft u.in])
Output
ans =
[3*[h], 30*[min]]
ans =
[5*[ft], 0]