isSymType
Tests the symbolic type of each element of an array.
Category: Symbolic Computations in MATLAB > Symbolic Variables, Expressions, Functions, and Preferences
Syntax
tf = isSymType(S, type)
Returns a logical array telling which elements of S are of type type.
Description
Only the object itself is classified, not its parts. isSymType(x + 1, 'variable') is false because the sum as a whole is an expression. Types form a hierarchy in which a more specific type also satisfies the general ones, so the integer 2 is of type 'integer' and also 'rational'.
For a symbolic array the test is applied to each element, which makes it handy for picking out the numeric entries of a mixed matrix.
Input arguments
S- Symbolic scalar or array.
type- Type name string, such as
'variable','integer','rational'or'expression'.
Output arguments
tf- Logical array of the same size as
S.
Example
Classifying the elements of a vector
syms x
v = [x, 2, x + 1, sym(1)/3];
isSymType(v, 'variable')
isSymType(v, 'integer')
isSymType(v, 'rational')
Output
ans = 1×4 logical array
1 0 0 0
ans = 1×4 logical array
0 1 0 0
ans = 1×4 logical array
0 1 0 1