Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

children

Subexpressions or terms of symbolic expression

Syntax


children(expr)
children(A)

Description

children(expr) returns a vector containing the child subexpressions of the symbolic expression expr. For example, the child subexpressions of a sum are its terms.

children(A) returns a cell array containing the child subexpressions of each expression in A.

Input Arguments

expr

Symbolic expression, equation, or inequality.

A

Vector or matrix of symbolic expressions, equations, or inequalities.

Examples

Find the child subexpressions of this expression. Child subexpressions of a sum are its terms.

syms x y
children(x^2 + x*y + y^2)
ans =
[ x*y, x^2, y^2]

Find the child subexpressions of this expression. This expression is also a sum, only some terms of that sum are negative.

children(x^2 - x*y - y^2)
ans =
[ -x*y, x^2, -y^2]

The child subexpression of a variable is the variable itself:

children(x)
ans =
x

Find the child subexpressions of this equation. The child subexpressions of an equation are the left and right sides of that equation.

syms x y
children(x^2 + x*y == y^2 + 1)
ans =
[ x^2 + y*x, y^2 + 1]

Find the child subexpressions of this inequality. The child subexpressions of an inequality are the left and right sides of that inequality.

children(sin(x) < cos(x))
ans =
[ sin(x), cos(x)]

Call the children function for this matrix. The result is the cell array containing the child subexpressions of each element of the matrix.

syms x y
s = children([x + y, sin(x)*cos(y); x^3 - y^3, exp(x*y^2)])
s =
  2×2 cell array
    [1×2 sym]    [1×2 sym]
    [1×2 sym]    [1×1 sym]

To access the contents of cells in the cell array, use braces:

s{1:4}
ans =
[ x, y]
 
ans =
[ x^3, -y^3]
 
ans =
[ cos(y), sin(x)]
 
ans =
x*y^2

Introduced in R2012a

Was this topic helpful?