Cell type (unit in some books) data is a special data type of MATLAB. It is flexible and can store arrays of different data types (characters, numbers) and different dimensions.
There are two ways to create:
1. Value assignment statement: assign a value directly to a unit, for example:
The subscript of the Content Index variable is enclosed in braces {}.
A {1, 1} = [1 2 3 4 5];
A {1, 2} = {'China'; 'yunnan '};
A {2, 1} = [1 + 1 * I, 4 * I]
The data in the unit index unit is enclosed by braces {}, and the unit subscript is enclosed by a common subscript.
A (1, 1) = {[1 2 3 4 5]};
A (1, 2) = {'China'; 'yunnan '}};
A (2, 1) = {[1 + 1 * I; 4 * I]}
2. Use the cell function: Cell Function to specify the cell size. You can assign values to the cell size after creation.
A = cell (2, 2)
View unit content
>
A =
[1x5 double] {2x1 cell}
[2x1 double] []
The above only shows the data structure. If you want to display the content, use celldisp
> Celldisp ()
A {1, 1} =
1 2 3 4 5
A {2, 1} =
1.0000 + 1.20. I
0 + 4. I I
A {1, 2} {1} =
China
A {1, 2} {2} =
Yunnan
A {2, 2} =
[]
The following is a summary of the confusing {}, [], ():
1) A = {'sy1', 'sy2', 'sy3'}; A is 1*3 cell
2) B = a B is 1*3 cell
3) B = [a] B is 1*3 cell
4) B = {A} B is 1*1 cell, B is only one cell of element , this element is still a 1*3 cell
5) C = B (1) c is 1*1 cell
6) D = B {1} D is 1*3 cell
7) d {1} d {1} is 'sy1'