cell函数举例
myCell = {A, B; C, D}
这里我们构造了一个2行2列的元胞数组, 其中A、B、C、D是四个矩阵。
C = {1, [2, 3]; [4; 5; 6], [7, 8; 9, 0; 0, 1]}
C =
[ 1] [1x2 double]
[3x1 double] [3x2 double]
>> M = cell2mat(C)
M =
1 2 3
4 7 8
5 9 0
6 0 1
c = mat2cell(x, [10, 20, 30], [25, 25])
divides a 60-by-50 array into six arrays contained in a cell array.

X = reshape(1:20,5,4)' C = mat2cell(X, [2 2], [3 2]) celldisp(C)
This code returns
X =
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
C =
[2x3 double] [2x2 double]
[2x3 double] [2x2 double]
C{1,1} =
1 2 3
6 7 8
C{2,1} =
11 12 13
16 17 18
C{1,2} =
4 5
9 10
C{2,2} =
14 15
19 20
C = mat2cell(X, [1 3]) celldisp(C)
This code returns
C =
[1x5 double]
[3x5 double]
C{1} =
1 2 3 4 5
C{2} =
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
浙公网安备 33010602011771号