Search code examples
arraysmatlabselectconcatenationcell-array

Vertically concatenate part of cell contents


In MatLab, all cells in my 60x1-cellarray contain a 10x1 double.

I would like to concatenate all these doubles vertically, except for the first number in every double.

My failed attempts was:

CellArray={[1 2 3];[1 2 3];[1 2 3]}
ContacenatedCellArray = vertcat(CellArray{:,1}(2:end))

This, obviously, did not work becauce CellArray{:,1} refers to multiple cells so that (2:end) is a bit silly.

Do you have any suggestions?

Thanks in advance!


Solution

  • Why not just do it in two lines:

    temp = vertcat(CellArray{:}); %// or cell2mat(CellArray)
    temp2 = temp(:,2:end)';
    ContacenatedCellArray = temp2(:);