Main Content

symFunType

Determine functional type of symbolic object

Description

s = symFunType(symObj) returns the functional type of a symbolic object.

  • If symObj is a symbolic function or a symbolic expression, then symFunType returns the topmost function name or operator of symObj. For example, syms x; symFunType(2*sin(x)) returns "times".

  • If symObj is not a symbolic function or a symbolic expression, then symFunType returns the same output as symType. For example, symFunType(sym('2')) returns "integer".

example

Examples

collapse all

Create an array of symbolic functions and expressions.

syms f(x)
expr = [f(x) sin(x) exp(x) int(f(x)) diff(f(x))]
expr = 

(f(x)sin(x)exf(x) dxx f(x))

Determine the functional type of each array element.

s = symFunType(expr)
s = 1x5 string
    "f"    "sin"    "exp"    "int"    "diff"

Create two symbolic expressions. Determine the topmost arithmetic operators of the expressions.

syms x
expr1 = x/(x^2+x+2);
expr2 = x + 1/(x^2+x+2);
s1 = symFunType(expr1)
s1 = 
"times"
s2 = symFunType(expr2)
s2 = 
"plus"

To return the terms separated by the operators, use children.

terms1 = children(expr1)
terms1=1×2 cell array
    {[x]}    {[1/(x^2 + x + 2)]}

terms2 = children(expr2)
terms2=1×2 cell array
    {[x]}    {[1/(x^2 + x + 2)]}

Create an array of symbolic equations and inequalities.

syms x y
eqns = [x+y==2, x<=5, y>3]
eqns = (x+y=2x53<y)

Determine the topmost comparison operator in each array element.

s = symFunType(eqns)
s = 1x3 string
    "eq"    "le"    "lt"

Input Arguments

collapse all

Symbolic objects, specified as symbolic expressions, symbolic functions, symbolic variables, symbolic numbers, or symbolic units.

Output Arguments

collapse all

Symbolic functional types, returned as a string array. If symObj is a symbolic function or a symbolic expression, then symFunType returns the topmost function name or operator of symObj. This table shows output values for various symbolic objects.

Symbolic Functional TypesReturned OutputInput Example
symbolic math functions"sin", "exp", "fourier", and so on — name of the topmost symbolic math function in a symbolic expressionsyms f(x); symFunType([sin(x), exp(x), fourier(f(x))])
unassigned symbolic functions

"f", "g", and so on — unassigned symbolic function

syms f(x) g(x); symFunType([f, g(x+2)])
arithmetic operators
  • "plus" — addition operator + and subtraction operator -

  • "times" — multiplication operator * and division operator /

  • "power" — power or exponentiation operator ^ and square root operator sqrt

  • syms x; symFunType(x^2-x)

  • syms x; symFunType(2*x^2)

  • syms x; symFunType([x^2 sqrt(x)])

equations and inequalities
  • "eq" — equality operator ==

  • "ne" — inequality operator ~=

  • "lt" — less-than operator < or greater-than operator >

  • "le" — less-than-or-equal-to operator <= or greater-than-or-equal-to operator >=

  • syms x y; symFunType(x==y)

  • syms x y; symFunType(x~=y)

  • syms x y; symFunType(x<y)

  • syms x y; symFunType(x>=y)

logical operators and constants
  • "or" — logical OR operator |

  • "and" — logical AND operator &

  • "not" — logical NOT operator ~

  • "xor" — logical exclusive-OR operator xor

  • "logicalconstant" — symbolic logical constants symtrue and symfalse

  • syms x y; symFunType(x|y)

  • syms x y; symFunType(x&y)

  • syms x; symFunType(~x)

  • syms x y; symFunType(xor(x,y))

  • symFunType([symtrue symfalse])

numbers
  • "integer" — integer number

  • "rational" — rational number

  • "vpareal" — variable-precision floating-point real number

  • "complex" — complex number

  • symFunType(sym('-1'))

  • symFunType(sym('1/2'))

  • symFunType([sym('1.5') vpa('3/2')])

  • symFunType(sym('1+2i'))

constants

"constant" — symbolic mathematical constant

symFunType(sym([pi catalan]))
variables

"variable"

symFunType(sym(x))
units

"unit"

symFunType(symunit('m'))
unsupported symbolic types"unsupported" 

Version History

Introduced in R2019a