This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Determine if input is a symbolic unit


tf = isUnit(expr)



tf = isUnit(expr) returns logical 1 (true) if expr is a unit, or a product of powers of units, and logical 0 (false) if it is not.


Determine if Input is a Unit

Determine if an expression is a symbolic unit by using isUnit.

Test if 3*u.m is a symbolic unit, where u = symunit. The isUnit function returns logical 0 (false) because 3*u.m contains the symbolic number 3.

u = symunit;
ans =

Check if u.m, u.mW, and x*u.Hz are units, where u = symunit. The isUnit function returns the array [1 1 0], meaning that the first two expressions are units but the third expression is not.

syms x
units = [u.m u.mW x*u.Hz];
ans =
  1×3 logical array
   1   1   0

Input Arguments

collapse all

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


  • 1 represents a dimensionless unit. Hence, isUnit(sym(1)) returns logical 1 (true).

Introduced in R2017a