问题
I have created 3d Cell array "mycell" of size 1x100x19.
val(:,:,1) =
Columns 1 through 3
{3x1 cell} {3x1 cell} {3x1 cell}
Columns 4 through 6
{3x1 cell} {3x1 cell} {3x1 cell}
Columns 7 through 13
[] [] [] [] [] [] [].....
val(:,:,2) =
Columns 1 through 7
[] [] [] [] [] [] []
Columns 8 through 13
{3x1 cell} [] [] [] [] []......
and so on till mycell(:,:,19).
As I cannot delete empty rows or colums, I concatenate using arrayfun like this:
mycell = arrayfun(@(x)cat(2, mycell{:,:,x}), 1:size(mycell, 3), 'uni', 0);
It gives me result like this:
Columns 1 through 3
{3x6 cell} {3x1 cell} {3x73 cell} ....
The result is okay but it is slow.Is there any way that I can do this with loop instead of arrayfun, because I check for loop is faster than arrayfun.
Any help will be appreciated.
来源:https://stackoverflow.com/questions/36749648/using-loop-instead-of-arrayfun-in-matlab