symType

Symbolic type of an object or of each element of an array.

Category: Symbolic Computations in MATLAB > Symbolic Variables, Expressions, Functions, and Preferences

Syntax

t = symType(S)

Returns the type name of S, or a string array with one name per element.

Description

symType gives the most specific type of what it is handed. A name such as x is a "variable", sym(2) an "integer", sym(1)/2 a "rational", sym(pi) a "constant", x + 1 an "expression" and x == 1 an "equation".

The result is the single best label, while isSymType answers whether an object belongs to a given type, including the more general ones.

Input arguments

S
Symbolic scalar or array.

Output arguments

t
String array of the same size as S, with names such as "variable", "integer", "rational", "complex", "constant", "expression" or "equation".

Example

Types of common objects

syms x
symType(x)
symType(sym(2))
symType(sym(1)/2)
symType(sym(pi))
symType(x + 1)
symType(x == 1)
symType([x 1])
Output
ans = "variable"
ans = "integer"
ans = "rational"
ans = "constant"
ans = "expression"
ans = "equation"
ans = 1×2 string array

    "variable"    "integer"

See also

isSymType hasSymType findSymType symFunType