Using loop instead of arrayfun in matlab
<p>I have created 3d Cell array "mycell" of size 1x100x19.</p>

<pre><code>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}    []    []    []    []    []......
</code></pre>

<p>and so on till mycell(:,:,19).</p>

<p>As I cannot delete empty rows or colums, I concatenate using arrayfun like this: </p>

<pre><code>mycell = arrayfun(@(x)cat(2, mycell{:,:,x}), 1:size(mycell, 3), 'uni', 0);
</code></pre>

<p>It gives me result like this: </p>

<pre><code>Columns 1 through 3

{3x6 cell}    {3x1 cell}    {3x73 cell} ....
</code></pre>

<p>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.</p>

<p>Any help will be appreciated.</p>