Cellular Array

Cellular array definition:

        basic components of a cellular array (Cell Array) is cellular, each element can be treated as a unit cell (the Cell), used to store various types of data, such as matrix, string, multidimensional array, cellular array structure array and the like. Cellular same cellular contents of each array may be different.

        From the definition of Ghost cells may be used to store various types of data this perspective, in matlab cellular array structure similar to the C language.
Cellular array dimension and the subscript:

        cellular array can be one-dimensional, two-dimensional or multi-dimensional, subscript distinguish each cell, with the same subscripts encoding matrix, and index into a single full mode index .
Cellular array created:

 1, to create directly {} "{}" cellular array to create and assign braces

    >> A = { 'which is a cellular array', [1 2 3 4] ; magic ( 3), { 'Hello', 'Hello'}}
    A =
      2 × 2 array Cell
        'which is a cellular array' [. 1. 4 × Double]
           [3 × 3 Double] {}. 1 × Cell 2
     
    >> whos A
      the Name Size Bytes Class    
      A 2x2 806 Cell       

analysis: Ghost created hungry cellular array cell A (1,1) is a string, A (1,2) is a matrix, A (2,1) is a matrix, A (2 ,



    >> B (1,1) = { 'This is the second cellular array'}
    B =
      Cell
        'which is a second cellular array'
     
    >> B (1,2) = {} 5i. 5 *
    B =
      1 × 2 cell arrays
        ' which is a second cellular array '[0.0000 + 25.0000i]
     
    >> B (l, 3) = {[2. 1;. 3. 4]}
    B =
      . 1 × Cell array. 3
        ' this is the first two yuan cell array '[0.0000 + 25.0000i] [2 × 2 Double]

. 3, each cellular content creation.

       This method is somewhat similar to the second method, confusion, note the difference () {} and during use.

       In cellular array A (1,2) represents a first line of cellular elements of the second column, A {1,2} denotes the content element stored

    >> A (1,2)
    ANS =
      Cell
        [. 1. 4 × Double]
     
    >> {1,2} A
    ANS =
         . 1 2. 4. 3

        From the above procedure, slowly taste different cellular and cellular elements stored in the content element; cellular elements which is merely illustrative of a "[1 × 4 double]" of the matrix, and the data type of matrix type double seen, cellular elements gives only data type. Cellular content stored in the array is the value of the cellular elements. If the C language more familiar friends, you can understand the value of the data type of the variable analog C language variables to understand it.

        Using the following method to create cellular contents by cellular, see below procedures, attention {} is used here instead of ().

    >> C {1,1} = { 'This is the third cellular array'}
    C =
      Cell
        {}. 1 × Cell. 1
     
    >> C = {1,2} Magic (. 4)
    C =
      . 1 × 2 array Cell
        {1 × 1 cell} [4 × 4 double]

SUMMARY cellular array display:

        use celldisp command displays the contents of the array cellular

    >> celldisp (a)
    a = {1,1}
     
    this is the first cellular array
    a 2,1} = {         
         . 8. 6. 1
         . 3. 5. 7
         . 4. 9 2
     
    A = {1,2}
         . 1 2. 4. 3
     
    A {2,2} {1} =
    hello
    A} {2} {2,2 & =
    Hello
     
    % As can be seen, the display cell array matlab Ghost default "column Display";

[Note] In cellular cellular acquisition method set as a {2,2} {1}, the second row indicates the contents of cellular elements stored in the second column of the array of cellular elements of the first cellular
content acquired cellular array:

1 obtaining elements of a cellular array (simple to understand fetch size specified elementary cells), with the parentheses "()" for acquiring the content designated elementary cells, "{}", to further acquire the content specified elementary cell with braces x3 = a {1,2} (1,4) , a {1,2} as a matrix, to obtain the specified element matrix (1,4); further acquires the content designated cellular content, x4 = a {2, 2} {1}, such as a {2,2} are cellular elements of the cellular array, cellular acquires the content of the first cellular elements stored in

    >> X1 = a (1,2)
    X1 =
      Cell
        [. 1. 4 × Double]% obtain cellular elements of the array, can be understood as cellular size
     
    >> X2 = a {1,2}
    X2 =
         . 1. 4. 3 2
     
    >> a X3 = {1,2} ( l, 4)
    X3 =
         . 4
     
    >> X4 = {A}. 1} {2,2 &
    X4 =
        'Hello'
----------------
Disclaimer: This article is CSDN blogger original article "aoxiang_ywj", and follow CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
Original link: https: //blog.csdn.net/baidu_37973494/article/details/86626631

Guess you like

Origin www.cnblogs.com/yibeimingyue/p/12077070.html