DocumentationHelp Center
Determine type of symbolic object
s = symType(symObj)
example
s = symType(symObj) returns the type of a symbolic object. For example, symType(sym('x')) returns "variable".
s
symObj
symType(sym('x'))
"variable"
collapse all
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 = 1x5 string "integer" "rational" "vpareal" "complex" "constant"
Create a symbolic function f(x) using syms.
f(x)
syms
syms f(x)
Determine the type of the function. Because f(x) is an unassigned symbolic function, it has the symbolic type "symfun".
"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
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^2
y(x) = 100-5 x2100 - 5*x^2
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 = 1x2 string "equation" "equation"
Solve the inequalities using solve. Return the solutions by setting 'ReturnConditions' to true.
solve
'ReturnConditions'
true
eqSol = solve([eq1 eq2], 'ReturnConditions', true); sols = eqSol.conditions
sols = x<18∧2<xx < sqrt(sym(18))&2 < x
Determine the symbolic type of the solutions.
s = symType(sols)
s = "logicalexpression"
Symbolic objects, specified as symbolic numbers, symbolic variables, symbolic expressions, symbolic functions, or symbolic units.
Symbolic types, returned as a string array. This table shows output values for various symbolic objects.
"integer"
symType(sym('-1'))
"rational"
symType(sym('1/2'))
"vpareal"
symType([sym('1.5') vpa('3/2')])
"complex"
symType(sym('1+2i'))
"constant"
symType(sym([pi catalan]))
syms x; symType(x)
syms f(x); symType(f)
"expression"
syms x; symType(sqrt(x))
"equation"
syms x; symType(x>=0)
"unit"
symType(symunit('meter'))
"logicalexpression"
syms x y; symType(x|y)
"logicalconstant"
symType([symtrue symfalse])
"unsupported"
symType
hasSymType | isSymType | sym | symfun | symFunType | syms
hasSymType
isSymType
sym
symfun
symFunType
귀하의 시스템에 이 예제의 수정된 버전이 있습니다. 이 버전을 대신 여시겠습니까?
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
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:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office