symType
Determine type of symbolic object
Syntax
Description
Examples
Create a symbolic number and determine its type.
a = sym('3/9');
s = symType(a)s = "rational"
Now construct a symbolic array by including symbolic numbers in the array elements. Determine the symbolic type of each array element.
B = [-5, a, vpa(a), 1i, pi]; s = symType(B)
s = 1×5 string
"integer" "rational" "vpareal" "complex" "constant"
Create a symbolic function f(x) using syms.
syms f(x)Determine the type of the function. Because f(x) is an unassigned symbolic function, it has the symbolic type "symfun".
s = symType(f)
s = "symfun"
Assigning a mathematical expression to f(x) changes its symbolic type.
f(x) = x^2; s = symType(f)
s = "expression"
Now check the symbolic type of f(x) = x and its derivative.
f(x) = x; s = symType(f)
s = "variable"
s = symType(diff(f))
s = "integer"
Determine the type of various symbolic objects when solving for inequalities.
Create a quadratic function.
syms y(x)
y(x) = 100 - 5*x^2y(x) =
Set two inequalities to the quadratic function. Check the symbolic type of each inequality.
eq1 = y(x) > 10; eq2 = x > 2; s = symType([eq1 eq2])
s = 1×2 string
"equation" "equation"
Solve the inequalities using solve. Return the solutions by setting 'ReturnConditions' to true.
eqSol = solve([eq1 eq2], 'ReturnConditions', true);
sols = eqSol.conditionssols =
Determine the symbolic type of the solutions.
s = symType(sols)
s = "logicalexpression"
Input Arguments
Symbolic objects, specified as symbolic numbers, symbolic variables, symbolic expressions, symbolic functions, or symbolic units.
Output Arguments
Symbolic types, returned as a string array. This table shows output values for various symbolic objects.
| Output | Description | Input Example |
|---|---|---|
"integer" | symbolic integer number | symType(sym('-1')) |
"rational" | symbolic rational number | symType(sym('1/2')) |
"vpareal" | symbolic variable-precision floating-point real number | symType([sym('1.5') vpa('3/2')]) |
"complex" | symbolic complex number | symType(sym('1+2i')) |
"constant" | symbolic mathematical constant | symType(sym([pi catalan])) |
"variable" | symbolic variable | syms x; symType(x) |
"symfun" | unassigned symbolic function | syms f(x); symType(f) |
"expression" | symbolic expression | syms x; symType(sqrt(x)) |
"equation" | symbolic equation and inequality | syms x; symType(x>=0) |
"unit" | symbolic unit | symType(symunit('meter')) |
"logicalexpression" | symbolic logical expression | syms x y; symType(x|y) |
"logicalconstant" | symbolic logical constant | symType([symtrue symfalse]) |
"unsupported" | symbolic object not supported by symType |
Version History
Introduced in R2019a
See Also
sym | syms | symfun | isSymType | symFunType | hasSymType
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)