主要内容

孩子们

符号表达式的子表达式或条件

从R2020b开始,语法subexpr =孩子(expr)一个标量输入expr返回subexpr作为一个<年代pan class="emphasis">嵌套单元阵列而不是一个向量。您可以使用印第安纳州subexpr =孩子(expr)子表达式返回单元阵列的索引。有关更多信息,请参见<一个href="//www.tatmou.com/it/it/help/symbolic/sym.children.html" class="intrnllnk">兼容性的考虑。

描述

例子

subexpr =孩子(<一个href="//www.tatmou.com/it/it/help/symbolic/#bs9fbt_-expr" class="intrnllnk">expr)返回一个嵌套单元阵列包含符号表达式的子表达式expr。例如,一笔的子表达式。

例子

subexpr =孩子(<一个href="//www.tatmou.com/it/it/help/symbolic/#bs9fbt_-A" class="intrnllnk">一个)返回一个嵌套单元阵列,其中包含每个表达式的子表达式的符号矩阵一个

例子

subexpr =孩子(<年代pan class="argument_placeholder">___,<一个href="//www.tatmou.com/it/it/help/symbolic/#mw_0ed6b4a5-22ba-4082-a6ba-0aa35b52a17a" class="intrnllnk">印第安纳州)返回一个符号表达式的子表达式<一个href="//www.tatmou.com/it/it/help/symbolic/#bs9fbt_-expr" class="intrnllnk">expr或一个符号矩阵<一个href="//www.tatmou.com/it/it/help/symbolic/#bs9fbt_-A" class="intrnllnk">一个作为一个单元阵列索引印第安纳州

例子

全部折叠

找到符号表达式的子表达式<年代pan class="inlineequation"> x 2 + x y + y 2 。嵌套的子表达式返回单元格数组。孩子们使用内部排序规则时返回的子表达式。你可以索引单元阵列的每个元素使用subexpr{我},在那里是细胞指数。一笔的子表达式。

信谊<年代pan style="color:#A020F0">xysubexpr =孩子(x ^ 2 + x * y + y ^ 2)
subexpr =<年代pan class="emphasis">1×3单元阵列{[x * y]} {[x ^ 2]} {[y ^ 2]}
s1 = subexpr {1}
s1 =<年代pan class="inlineequation">
                       
                        
                         
                          
                           
                            x
                           
                           
                           
                            y
                          
                         
                        
                       
s2 = subexpr {2}
s2 =<年代pan class="inlineequation">
                       
                        
                         
                          
                           
                            x
                          
                          
                           
                            2
                          
                         
                        
                       
s3 = subexpr {3}
s3 =<年代pan class="inlineequation">
                       
                        
                         
                          
                           
                            y
                          
                          
                           
                            2
                          
                         
                        
                       

你也可以索引子表达式的每个元素指定索引印第安纳州孩子们函数。

s1 =孩子(x ^ 2 + x * y + y ^ 2, 1)
s1 =<年代pan class="inlineequation">
                       
                        
                         
                          
                           
                            x
                           
                           
                           
                            y
                          
                         
                        
                       
s2 =孩子(x ^ 2 + x * y + y ^ 2, 2)
s2 =<年代pan class="inlineequation">
                       
                        
                         
                          
                           
                            x
                          
                          
                           
                            2
                          
                         
                        
                       
s3 =孩子(x ^ 2 + x * y + y ^ 2, 3)
s3 =<年代pan class="inlineequation">
                       
                        
                         
                          
                           
                            y
                          
                          
                           
                            2
                          
                         
                        
                       

将单元阵列的子表达式转化为一个向量,可以使用命令[subexpr {}):

V = [subexpr {}):
V =<年代pan class="inlineequation">
                       
                        
                         
                          
                           (
                          
                           
                            
                             
                              
                               
                                
                                 x
                                
                                
                                
                                 y
                               
                              
                             
                            
                            
                             
                              
                               
                                
                                 x
                               
                               
                                
                                 2
                               
                              
                             
                            
                            
                             
                              
                               
                                
                                 y
                               
                               
                                
                                 2
                               
                              
                             
                            
                           
                          
                          
                           )
                         
                        
                       

找到方程的子表达式<年代pan class="inlineequation"> x 2 + x y = y 2 + 1 。方程的子表达式1×2细胞中返回数组。索引单元阵列的所有元素。一个方程的子表达式的左右方程。

信谊<年代pan style="color:#A020F0">xysubexpr =孩子(x ^ 2 + x * y = = y ^ 2 + 1)
subexpr =<年代pan class="emphasis">1×2单元阵列{[x ^ 2 + y * x]} {[y ^ 2 + 1]}
subexpr {:}
ans =<年代pan class="inlineequation">
                       
                        
                         
                          
                           
                            
                             
                              x
                            
                            
                             
                              2
                            
                           
                           
                            +
                           
                            
                             
                              y
                             
                             
                             
                              x
                            
                           
                          
                         
                        
                       
ans =<年代pan class="inlineequation">
                       
                        
                         
                          
                           
                            
                             
                              y
                            
                            
                             
                              2
                            
                           
                           
                            +
                           
                            1
                          
                         
                        
                       

接下来,找到子表达式的不平等<年代pan class="inlineequation"> ( x ) < 因为 ( x ) 。索引返回单元阵列的所有元素。的子表达式的左右是不平等,不平等。

subexpr =孩子(sin (x) < cos (x))
subexpr =<年代pan class="emphasis">1×2单元阵列(sin (x)) {} {[cos (x)]}
subexpr {:}
ans =<年代pan class="inlineequation">
                       
                        
                         
                          
                           
                          
                          
                           
                            (
                           
                            
                             
                              x
                            
                           
                           
                            )
                          
                         
                        
                       
ans =<年代pan class="inlineequation">
                       
                        
                         
                          
                           
                            因为
                          
                          
                           
                            (
                           
                            
                             
                              x
                            
                           
                           
                            )
                          
                         
                        
                       

的子表达式一个积分<年代pan class="inlineequation"> 一个 b f ( x ) d x 。的子表达式返回单元阵列的符号表达式。

信谊<年代pan style="color:#A020F0">f (x)一个bsubexpr =孩子(int (f (x), a, b))
subexpr =<年代pan class="emphasis">1×4单元阵列(f (x)) {} {[x]}{[一]}{[b]}
V = [subexpr {}):
V =<年代pan class="inlineequation">
                       
                        
                         
                          
                           (
                          
                           
                            
                             
                              
                               
                                
                                 f
                               
                               
                                
                                 (
                                
                                 
                                  
                                   x
                                 
                                
                                
                                 )
                               
                              
                             
                            
                            
                             
                              
                               x
                             
                            
                            
                             
                              
                               一个
                             
                            
                            
                             
                              
                               b
                             
                            
                           
                          
                          
                           )
                         
                        
                       

找到的泰勒近似<年代pan class="inlineequation"> 因为 ( x ) 函数附近<年代pan class="inlineequation"> x = 2

信谊<年代pan style="color:#A020F0">xt =泰勒(cos (x), x, 2)
t =
                       

因为 ( 2 ) + ( 2 ) x - - - - - - 2 3 6 - - - - - - ( 2 ) x - - - - - - 2 5 120年 - - - - - - ( 2 ) x - - - - - - 2 - - - - - - 因为 ( 2 ) x - - - - - - 2 2 2 + 因为 ( 2 ) x - - - - - - 2 4 24

隔开的泰勒展开有六个方面<年代pan class="inlineequation"> + 或<年代pan class="inlineequation"> - - - - - - 的迹象。

画出<年代pan class="inlineequation"> 因为 ( x ) 函数。使用孩子们分开的扩张。表明,泰勒展开近似函数更密切更方面都包括在内。

fplot (cos (x) [0 4])<年代pan style="color:#A020F0">在s = 0;<年代pan style="color:#0000FF">为我= 1:6 s = s +孩子(t,我);fplot ([0 4],<年代pan style="color:#A020F0">“——”)<年代pan style="color:#0000FF">结束传奇({<年代pan style="color:#A020F0">“cos (x)”,<年代pan style="color:#A020F0">' 1 ",<年代pan style="color:#A020F0">“两项”,<年代pan style="color:#A020F0">“三方面”,<年代pan style="color:#A020F0">“四项”,<年代pan style="color:#A020F0">“五项”,<年代pan style="color:#A020F0">“六项”})

图包含一个坐标轴对象。坐标轴对象包含7 functionline类型的对象。这些对象代表cos (x), 1项,2项,3,4,5,6项。

调用孩子们函数来找到以下符号矩阵的子表达式的输入。结果是一个2——- - - - - -2嵌套单元阵列包含矩阵的每个元素的子表达式。

信谊<年代pan style="color:#A020F0">xysymM = [x + y, sin (x) * cos (y);x ^ 3 - y ^ 3, exp (x * y ^ 2) + 3]
symM =
                       

( x + y 因为 ( y ) ( x ) x 3 - - - - - - y 3 e x y 2 + 3 )

s =孩子(symM)
s =<年代pan class="emphasis">2×2单元阵列{1 x2细胞}{1 x2细胞}{1 x2细胞}{1 x2细胞}

unnest运算或访问的元素嵌套单元阵列年代,使用括号。例如,{1}-的元素年代是一个1——- - - - - -2单元阵列的符号表达式。

s11 s = {1}
s11 =<年代pan class="emphasis">1×2单元阵列{[x]} {[y]}

Unnest运算的每个元素年代使用括号。嵌套细胞数组转换成向量使用方括号。

s11vec = [s {1} {}):
s11vec =<年代pan class="inlineequation">
                       
                        
                         
                          
                           (
                          
                           
                            
                             
                              
                               x
                             
                            
                            
                             
                              
                               y
                             
                            
                           
                          
                          
                           )
                         
                        
                       
s21vec = [s {1}, {}):
s21vec =<年代pan class="inlineequation">
                       
                        
                         
                          
                           (
                          
                           
                            
                             
                              
                               
                                
                                 x
                               
                               
                                
                                 3
                               
                              
                             
                            
                            
                             
                              
                               
                                
                                 - - - - - -
                                
                                 
                                  
                                   y
                                 
                                 
                                  
                                   3
                                 
                                
                               
                              
                             
                            
                           
                          
                          
                           )
                         
                        
                       
s12vec = [s {1,2} {}):
s12vec =<年代pan class="inlineequation">
                       
                        
                         
                          
                           (
                          
                           
                            
                             
                              
                               
                                
                                 因为
                               
                               
                                
                                 (
                                
                                 
                                  
                                   y
                                 
                                
                                
                                 )
                               
                              
                             
                            
                            
                             
                              
                               
                                
                               
                               
                                
                                 (
                                
                                 
                                  
                                   x
                                 
                                
                                
                                 )
                               
                              
                             
                            
                           
                          
                          
                           )
                         
                        
                       
s22vec = [s {2,} {}):
s22vec =<年代pan class="inlineequation">
                       
                        
                         
                          
                           (
                          
                           
                            
                             
                              
                               
                                
                                 e
                               
                               
                                
                                 
                                  
                                   x
                                  
                                  
                                  
                                   
                                    
                                     y
                                   
                                   
                                    
                                     2
                                   
                                  
                                 
                                
                               
                              
                             
                            
                            
                             
                              
                               3
                             
                            
                           
                          
                          
                           )
                         
                        
                       

如果每个元素的嵌套单元阵列年代包含一个嵌套细胞相同大小的数组,然后还可以使用印第安纳州输入参数来访问元素的嵌套单元阵列。该指数印第安纳州允许孩子们访问子表达式的符号矩阵的每一列输入symM

scol1 =孩子(symM, 1)
scol1 =<年代pan class="emphasis">2×2单元阵列{[x]} {[cos (y)]} {[x ^ 3]} {[exp (x * y ^ 2)]}
[scol1 {}):”。
ans =
                       

( x x 3 因为 ( y ) e x y 2 )

scol2 =孩子(symM, 2)
scol2 =<年代pan class="emphasis">2×2单元阵列{[y]} {[sin (x)]} {[- y ^ 3]} {[3]}
[scol2 {}):”。
ans =
                       

( y - - - - - - y 3 ( x ) 3 )

输入参数

全部折叠

输入表达式,指定为一个象征性的数字,变量,函数,或表达。

输入矩阵,指定为一个符号矩阵。

索引返回的子表达式,指定为一个正整数。

  • 如果孩子(expr)子表达式返回一个嵌套单元阵列,然后索引儿童(expr,印第安纳州)返回印第安纳州单元阵列的th元素。

  • 如果孩子(一个)子表达式返回一个嵌套单元阵列,每个细胞元素具有相同的大小,然后索引孩子(印第安纳州)返回印第安纳州嵌套的th列单元阵列。

版本历史

介绍了R2012a

全部展开

另请参阅

|<年代pan itemscope itemtype="//www.tatmou.com/help/schema/MathWorksDocPage/SeeAlso" itemprop="seealso">|<年代pan itemscope itemtype="//www.tatmou.com/help/schema/MathWorksDocPage/SeeAlso" itemprop="seealso">|<年代pan itemscope itemtype="//www.tatmou.com/help/schema/MathWorksDocPage/SeeAlso" itemprop="seealso">|<年代pan itemscope itemtype="//www.tatmou.com/help/schema/MathWorksDocPage/SeeAlso" itemprop="seealso">