# findUnits

Find units in input

## Description

example

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

## 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 = $\left(\begin{array}{cc}\mathrm{N}\mathrm{"newton - a physical unit of force."}& \mathrm{m}\mathrm{"meter - a physical unit of length."}\end{array}\right)$

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 = $\left(\begin{array}{ccccc}\mathrm{K}\mathrm{"kelvin - a physical unit of temperature."}& \mathrm{N}\mathrm{"newton - a physical unit of force."}& \mathrm{kg}\mathrm{"kilogram - a physical unit of mass."}& \mathrm{m}\mathrm{"meter - a physical unit of length."}& \mathrm{s}\mathrm{"second - a physical unit of time."}\end{array}\right)$

## 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