isUnit
Determine if input is a symbolic unit
Syntax
Description
Examples
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; isUnit(3*u.m)
ans = logical 0
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]; isUnit(units)
ans = 1×3 logical array 1 1 0
Input Arguments
Tips
1represents a dimensionless unit. Hence,isUnit(sym(1))returns logical1(true).
Version History
Introduced in R2017a