Task 04: unit array

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/weixin_45138230/article/details/102712286

Creating an array of unit

C = cell (n) establishing unit empty square of order n
C = cell (m, n) establishing unit empty matrix of m rows and n columns
C = cell (size (A) ) to create an empty cell matrix with the same dimension A rectangular

Assignment

  1. Subscript Index
>> A (1,1) = {magic(3)};
>>  A (1,2) = {'10/1/2004'};
>> A
A =
  1×2 cell 数组
    {3×3 double}    {'10/1/2004'}
>> celldisp (A)
A{1} =
     8     1     6
     3     5     7
     4     9     2
A{2} =
10/1/2004
>> 

  1. Index unit
>> A {1,1} = magic(3);
>> A {1,2} = '10/1/2004';
>> celldisp(A)
A{1} =
     8     1     6
     3     5     7
     4     9     2
A{2} =
10/1/2004
>> 

Delete and rewrite

>> A = {magic(3), '10/1/2005', 'name_wang'; [1 3 5 7], eye(3),'$2000'}
A =
  2×3 cell 数组
    {3×3 double}    {'10/1/2005'}    {'name_wang'}
    {1×4 double}    {3×3 double }    {'$2000'    }
>> A{1,1} = []
A =
  2×3 cell 数组
    {0×0 double}    {'10/1/2005'}    {'name_wang'}
    {1×4 double}    {3×3 double }    {'$2000'    }

Operation

Here Insert Picture Description

>> A = cell(2,3)
A =
  2×3 cell 数组
    {0×0 double}    {0×0 double}    {0×0 double}
    {0×0 double}    {0×0 double}    {0×0 double}
>> A{1,1} = rand(2,3);
>> A{1,2} = rand(3,2);
>> A{2,1} = [1 3 5 7];
>> A{2,2} = 1:4;
>> A{1,3} = A{1,1} * A{1,2};
>> A{2,3} = conv(A{2,1}, A{2,2})
A =
  2×3 cell 数组
    {2×3 double}    {3×2 double}    {2×2 double}
    {1×4 double}    {1×4 double}    {1×7 double}
>> celldisp(A)
A{1,1} =
    0.8147    0.1270    0.6324
    0.9058    0.9134    0.0975
A{2,1} =
     1     3     5     7
A{1,2} =
    0.2785    0.9649
    0.5469    0.1576
    0.9575    0.9706
A{2,2} =
     1     2     3     4
A{1,3} =
    0.9018    1.4199
    0.8452    1.1126
A{2,3} =
     1     5    14    30    41    41    28
>> 

Supplementary: clear all variables can delete a workspace

Guess you like

Origin blog.csdn.net/weixin_45138230/article/details/102712286