Main Content

findUnits

Find units in input

Description

U = findUnits(expr) returns a row vector of units in the symbolic expression expr.

example

Examples

collapse all

Find the units in an expression by using findUnits.

u = symunit;
syms x
units = findUnits(x*u.m + 2*u.N)
units = (N"newton - a physical unit of force."m"meter - a physical unit of length.")

Find the units in an array of equations or expressions by using findUnits. The findUnits function concatenates all units found in the input to return a row vector of units. findUnits returns only base units.

u = symunit;
array = [2*u.m + 3*u.K, 1*u.N == 1*u.kg/(u.m*u.s^2)];
units = findUnits(array)
units = (K"kelvin - a physical unit of temperature."N"newton - a physical unit of force."kg"kilogram - a physical unit of mass."m"meter - a physical unit of length."s"second - a physical unit of time.")

Input Arguments

collapse all

Input, specified as a symbolic number, variable, vector, matrix, multidimensional array, function, or a symbolic expression.

Version History

Introduced in R2017a