1

I have an array of different size matrices.I would like to create n arrays each including equal size matrices. So if I have:

 ArrayA =
 <9x10 double>
 <7x10 double>
 <9x10 double>
 <9x10 double>
 <7x10 double>

I would like to obtain:

ArrayA1 =
<9x10 double>
<9x10 double>
<9x10 double>

ArrayA2 =    
<7x10 double>
<7x10 double>
4

1 回答 1

1
mat = 

[4x5 double]
[4x5 double]
[5x5 double]
[4x5 double]
[5x5 double]
[6x5 double]
[5x5 double]

我假设 all are nx5,因此只检查行。

arr_sizes =  arrayfun(@(x) size(mat{x},1),1:size(mat,1))'

这给出了:

arr_sizes =

 4
 4
 5
 4
 5
 6
 5

现在:

[~, ~, idx] = unique(arr_sizes);

最终输出将是:

tot_arr = arrayfun(@(x) mat(idx == x), 1:max(idx),'UniformOutput',false)';

tot_arr =

{3x1 cell}
{3x1 cell}
{1x1 cell}

现在,tot_arr包含 3 个数组,您调用的数组ArrayA1, ArrayA2等。

tot_arr{1}

ans = 

[4x5 double]
[4x5 double]
[4x5 double]
于 2013-06-14T15:50:32.093 回答