hasSymType
Determine whether symbolic object contains specific type
Description
Examples
Symbolic Variable, Constant, or Number
Determine whether a symbolic expression contains a symbolic variable, constant, or number of a specific type.
Create a symbolic expression.
syms x; expr = sym('1/2') + 2*pi + x
expr =
Check whether expr
contains a symbolic variable of type 'variable'
.
TF = hasSymType(expr,'variable')
TF = logical
1
Check whether expr
contains a symbolic constant of type 'constant'
.
TF = hasSymType(expr,'constant')
TF = logical
1
Check whether expr
contains a symbolic number of type 'integer'
.
TF = hasSymType(expr,'integer')
TF = logical
1
Check whether expr
contains a symbolic number of type 'integer | real'
.
TF = hasSymType(expr,'integer | real')
TF = logical
1
Check whether expr
contains a symbolic number of type 'complex'
.
TF = hasSymType(expr,'complex')
TF = logical
0
Symbolic Function or Operator
Determine whether a symbolic equation contains a symbolic function or operator of a specific type.
Create a symbolic equation.
syms f(x) n eq = f(x^n) + int(f(x),x) + vpa(2.7) == 1i
eq =
Check whether eq
contains the symbolic function 'f'
.
TF = hasSymType(eq,'f')
TF = logical
1
Check whether eq
contains an unassigned symbolic function of type 'symfun'
.
TF = hasSymType(eq,'symfun')
TF = logical
1
Check whether eq
contains a symbolic math function of type 'int'
.
TF = hasSymType(eq,'int')
TF = logical
1
Check whether eq
contains an operator of type 'power'
.
TF = hasSymType(eq,'power')
TF = logical
1
Function of Multiple Variables
Create a symbolic function of multiple variables using syms
.
syms f(x,y,z)
g = f + x*y + pi
g(x, y, z) =
Check whether g
depends on the exact variable x
using 'symfunOf'
.
TF = hasSymType(g,'symfunOf',x)
TF = logical
0
Check whether g
depends on the exact sequence of variables [x y z]
using 'symfunOf'
.
TF = hasSymType(g,'symfunOf',[x y z])
TF = logical
1
Check whether g
has any dependency on the variables [y x]
using 'symfunDependingOn'
.
TF = hasSymType(g,'symfunDependingOn',[y x])
TF = logical
1
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 | Examples Returning Logical 1 |
---|---|---|
numbers |
|
|
constants | 'constant' — symbolic mathematical constants,
including 'number' | hasSymType([sym(pi) vpa(1i)],'constant') |
symbolic math functions | 'vpa' , 'sin' ,
'exp' , and so on — symbolic math functions in symbolic
expressions | hasSymType(vpa(sym(pi)),'vpa') |
unassigned symbolic functions |
|
|
arithmetic operators |
|
|
variables | 'variable' — symbolic variables | hasSymType(sym('x'),'variable') |
units | 'unit' — symbolic units | hasSymType(symunit('m'),'unit') |
expressions | 'expression' — symbolic expressions, including all of
the preceding symbolic types | hasSymType(sym('x')+1,'expression') |
logical expressions |
|
|
equations and inequalities |
|
|
unsupported symbolic types |
|
funType
— Function type
'symfunOf'
| 'symfunDependingOn'
Function type, specified as 'symfunOf'
or
'symfunDependingOn'
.
'symfunOf'
checks whethersymObj
contains an unassigned symbolic function that depends on the exact sequence of variables specified by the arrayvars
. For example,syms f(x,y); hasSymType(f,'symfunOf',[x y])
returns logical1
.'symfunDependingOn'
checks whethersymObj
contains an unassigned symbolic function that has a dependency on the variables specified by the arrayvars
. For example,syms f(x,y); hasSymType(f,'symfunDependingOn',[y x])
returns logical1
.
vars
— Input variables
symbolic variables | symbolic array
Input variables, specified as symbolic variables or a symbolic array.
Tips
To check whether a symbolic expression contains a particular subexpression, use the
has
function.
Version History
Introduced in R2019a
See Also
has
| symFunType
| isSymType
| symType
| sym
| syms
| mapSymType
| findSymType
MATLAB-Befehl
Sie haben auf einen Link geklickt, der diesem MATLAB-Befehl entspricht:
Führen Sie den Befehl durch Eingabe in das MATLAB-Befehlsfenster aus. Webbrowser unterstützen keine MATLAB-Befehle.
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)