Main Content


Find units in input



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


Find Units in Expression

Find the units in an expression by using findUnits.

u = symunit;
syms x
units = findUnits(x*u.m + 2*u.N)
units =
[ [N], [m]]

Find Units in Array of Equations or Expressions

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.s^2)];
units = findUnits(array)
units =
[ [K], [N], [kg], [m], [s]]

Input Arguments

collapse all

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

Introduced in R2017a