children
Subexpressions that form the operands of a symbolic expression.
Category: Symbolic Computations in MATLAB > Symbolic Variables, Expressions, Functions, and Preferences
Syntax
c = children(S)
Returns the operands of the top-level operation of S.
Description
children looks at the outermost operation of an expression and returns its arguments. For a sum it returns the terms, for a product the factors, for sin(x) the argument x. Applying it repeatedly walks the expression tree down to the variables and constants.
The order of the terms is the internal order of the expression, which need not be the order in which it was typed. The input must be a scalar expression, not a symbolic array.
Input arguments
S- Scalar symbolic expression.
Output arguments
c- Row vector of subexpressions. A symbolic variable or number is its own single child.
Example
Taking an expression apart
syms a b
expr = (a + b)*sin(a);
children(expr)
children(sin(a))
children(a + b)
Output
ans =
[a + b, sin(a)]
ans = a
ans =
[a, b]