Let's pretend that
A = cellfun(@(~)rand(121,1), cell(4,5), 'uniformoutput', false)
then usually i would say
cat(3, A{:})
but this will give a 121 by 1 by 20 matrix. For your case an additional step is needed:
A = cellfun(@(x)permute(x,3,2,1), A, 'uniformoutput', false) A = reshape([A{:}], size(A,1), size(A,2), size(A{1},3))
or alternatively
A = cellfun(@(x)permute(x,3,2,1), A, 'uniformoutput', false) A = cell2mat(A);
although
>> start = tic; >> for ii = 1:1e3 >> B1 = reshape([A{:}], size(A,1), size(A,2), size(A{1},3)); end >> time1 = toc(start); >> >> start = tic; >> for ii = 1:1e3 >> B2 = cell2mat(A); end >> time2 = toc(start); >> >> time2/time1 ans = 4.964318459657702e+00
therefore, the cell2mat command cell2mat almost 5 times slower than the reshape extension. Use what works best for your business.
Rody oldenhuis
source share