Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

concatenate vectors of an cell array in matlab

In matlab I have a 4x5 cell array where each cell consists of an 121x1 vector.

What is the easiest way to create an 3-dim 4x5x121 matrix avoiding a 2-fold loop.

like image 794
user1618022 Avatar asked Oct 22 '12 09:10

user1618022


1 Answers

One way (not necessarily the fastest)

%# convert all arrays in the cell array inCell to 1x1x121
permCell = cellfun(@(x)permute(x,[3,2,1]),inCell,'uniformOutput',false);

%# catenate
array = cell2mat(permCell);
like image 90
Jonas Avatar answered Sep 30 '22 09:09

Jonas