hasSymType
Determine whether symbolic object contains specific type
Description
Examples
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
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
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
Symbolic objects, specified as symbolic expressions, symbolic functions, symbolic variables, symbolic numbers, or symbolic units.
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 |
|
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
.
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 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.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- 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)