findSymType
Find symbolic subobjects of specific type
Description
returns a vector of symbolic subobjects of type X
= findSymType(symObj
,type
)type
from the symbolic
object symObj
. The input type
must be a case-sensitive
string scalar or character vector, and it can include a logical expression.
If
symObj
does not contain a symbolic subobject of typetype
, thenfindSymType
returns an empty scalar.If
symObj
contains several subexpressions of typetype
, thenfindSymType
returns the largest matching subexpression.
Examples
Symbolic Number and Constant
Find and return specific symbolic numbers and constants in a symbolic expression.
Create a symbolic expression.
expr = sym('1/2')*pi + vpa(pi)
expr =
Find symbolic numbers of type 'integer'
.
X = findSymType(expr,'integer')
X =
Find symbolic numbers of type 'integer | real'
.
X = findSymType(expr,'integer | real')
X =
Find symbolic numbers of type 'vpareal'
.
X = findSymType(expr,'vpareal')
X =
Find symbolic numbers of type 'complex'
.
X = findSymType(expr,'complex')
X = Empty sym: 1-by-0
The findSymType
function returns an empty scalar since the expression expr
does not contain any complex numbers.
Now find symbolic constant of type 'constant'
.
X = findSymType(expr,'constant')
X =
When there are several subexpressions of type 'constant'
, findSymType
returns the largest matching subexpression.
Symbolic Variable and Function
Find and return symbolic variables and functions in a symbolic equation.
Create a symbolic equation.
syms y(t) k eq = diff(y) + k*y == sin(y)
eq(t) =
Find symbolic variables of type 'variable'
in the equation.
X = findSymType(eq,'variable')
X =
Find an unassigned symbolic function of type 'symfun'
in the equation.
X = findSymType(eq,'symfun')
X =
Find a symbolic math function of type 'diff'
in the equation.
X = findSymType(eq,'diff')
X =
Symbolic Function of Specific Variables
Find and return symbolic functions with specific variable dependencies in an expression.
Create a symbolic expression.
syms n f(x) g(x) y(x,t) expr = x + f(x^n) + g(x)+ y(x,t)
expr =
Find unassigned symbolic functions of type 'symfun'
in the expression.
X = findSymType(expr,'symfun')
X =
Find symbolic functions that depend on the exact sequence of variables [x t]
using 'symfunOf'
.
X = findSymType(expr,'symfunOf',[x t])
X =
Find symbolic functions that have a dependency on the variable x using 'symfunDependingOn'
.
X = findSymType(expr,'symfunDependingOn',x)
X =
Input Arguments
symObj
— Symbolic objects
symbolic expressions | symbolic functions | symbolic variables | symbolic numbers | symbolic units
Symbolic objects, specified as symbolic expressions, symbolic functions, symbolic variables, symbolic numbers, or symbolic units.
type
— Symbolic types
scalar string | character vector
Symbolic types, specified as a case-sensitive scalar string or character vector. The
input type
can contain a logical expression. The value options
follow.
Symbolic Type Category | String Values |
---|---|
numbers |
|
constants | 'constant' — symbolic mathematical constants,
including 'number' |
symbolic math functions | 'vpa' , 'sin' ,
'exp' , and so on — symbolic math functions in symbolic
expressions |
unassigned symbolic functions |
|
arithmetic operators |
|
variables | 'variable' — symbolic variables |
units | 'unit' — symbolic units |
expressions | 'expression' — symbolic expressions, including all of
the preceding symbolic types |
logical expressions |
|
equations and inequalities |
|
unsupported symbolic types |
|
If symObj
contains several subexpressions of type
type
, then findSymType
returns the largest
matching subexpression (topmost matching node in a tree data structure).
funType
— Function type
'symfunOf'
| 'symfunDependingOn'
Function type, specified as 'symfunOf'
or
'symfunDependingOn'
.
'symfunOf'
finds and returns the unassigned symbolic functions that depend on the exact sequence of variables specified by the arrayvars
. For example,syms f(x,y); findSymType(f,'symfunOf',[x y])
returnsf(x,y)
.'symfunDependingOn'
finds and returns the unassigned symbolic functions that have a dependency on the variables specified by the arrayvars
. For example,syms f(x,y); findSymType(f,'symfunDependingOn',x)
returnsf(x,y)
.
vars
— Input variables
symbolic variables | symbolic array
Input variables, specified as symbolic variables or a symbolic array.
Version History
Introduced in R2019a
See Also
symFunType
| hasSymType
| symType
| sym
| syms
| isSymType
| mapSymType
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)