findSymType
Finds the subexpressions of a given symbolic type.
Category: Symbolic Computations in MATLAB > Symbolic Variables, Expressions, Functions, and Preferences
Syntax
found = findSymType(S, type)
Returns every subexpression of S whose type is type.
Description
The whole expression tree is searched, not only the top level. With 'variable' the result lists the symbolic variables in use; with 'integer' it lists every integer constant, including exponents and coefficients; with a function name it lists each distinct call of that function.
Use symType to find out which type name applies to a given object.
Input arguments
S- Symbolic expression.
type- Type name as a string, such as
'variable','integer','rational'or a function name like'sin'.
Output arguments
found- Symbolic row vector of the matching subexpressions, without repeats. Empty when nothing matches.
Example
Variables, integers and function calls
syms x
S = x^2 + 3*x + sin(x);
findSymType(S, 'variable')
findSymType(S, 'integer')
findSymType(S, 'sin')
Output
ans = x
ans =
[2, 3]
ans = sin(x)