-1

假设我有 C 单元,如下所述:

C =

[31, 17]      [57, 17]       [83, 17]      [109, 17]     [135, 17]
[31, 33]      [57, 33]       [83, 33]      [109, 33]     [135, 33]
[31, 49]      [57, 49]       [83, 49]      [109, 49]     [135, 49]
[31, 65]      [57, 65]       [83, 65]      [109, 65]     [135, 65]
[31, 81]      [57, 81]       [83, 81]      [109, 81]     [135, 81]
[31, 97]      [57, 97]       [83, 97]      [109, 97]     [135, 97]
[31, 113]     [57, 113]      [83, 113]     [109, 113]    [135, 113]
[31, 129]     [57, 129]      [83, 129]     [109, 129]    [135, 129]
[31, 145]     [57, 145]      [83, 145]     [109, 145]    [135, 145]
[31, 161]     [57, 161]      [83, 161]     [109, 161]    [135, 161]
[31, 177]     [57, 177]      [83, 177]     [109, 177]    [135, 177]

现在我想在新的矩阵中提取所有数据,
如下所示:

C11 = ([31,17] [57,17]; [31,33] [57,33])          
C12 = ([57,17] [83,17]; [57,33] [83,33])                       
C13 = ([83,17] [109,17]; [83,33] [109,33])    
C14 = ([109,17] [135,17]; [109,33] [135,33])    
C21 = ([31,33] [57,33]; [31,49] [57,49])                           
C22 = ([57,33] [83,33]; [57,49] [83,49])
C23 = ([83,33] [109,33]; [83,49] [109,49]) 

....... ........ ....... ...... ..               

C104 = ([109,161] [135,161]; [109,177] [109,177])

在 Matlab 中如何做到这一点?

4

1 回答 1

0

只需使用带圆括号的数组下标。例如 ,C12会这样计算:

>> C12(1:2, 2:3)

ans =
    { [ 57 17 ]    [ 83 17 ] }
    { [ 57 33 ]    [ 83 33 ] }

您可以执行一个 for 循环来遍历您的单元格数组并逐个提取必要的单元格,并将每个单元格存储在不同的变量中。但是,所有的数据都已经存储了C,为什么要复制呢?我建议您将所有内容保存在一个单元格数组中,并仅在需要时提取矩阵。

于 2013-03-21T13:54:29.727 回答