Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 700
Nightingale Avatar asked Mar 21 '23 06:03

Nightingale


2 Answers

Why not just do it in two lines:

temp = vertcat(CellArray{:}); %// or cell2mat(CellArray)
temp2 = temp(:,2:end)';
ContacenatedCellArray = temp2(:);
like image 152
Dan Avatar answered Apr 05 '23 20:04

Dan


Try this -

%%// Vertically concatenated array
ContacenatedCellArray = cell2mat(CellArray); 

%%// Use the first index of every double array to remove those
ContacenatedCellArray(1:10:end)=[]; 
like image 41
Divakar Avatar answered Apr 05 '23 22:04

Divakar