How to organise cell array data into a single table

I have a 50x1 cell array (document attached) where each cell is a double array organised as follows: (T, Xi, Yi), where T is time, and Xi and Yi are coordinates of points in cell ix1. I want to organise all these data into a single table where T is in the first column, and the coordinate Xi and Yi are successively organised in the next columns. It would eventually look like that (T, X1, Y1, X2, Y2..., Xn, Yn). Any idea what I could try ? Thanks. Coz

답변 (1개)

Andrei Bobrov
Andrei Bobrov 2017년 8월 2일
편집: Andrei Bobrov 2017년 8월 2일
N = ["X";"Y"] + string(1:numel(coordinates));
k = N(:)';
k = [{'T'},{k{:}}];
n = cellfun('size',coordinates,1);
[m,id] = max(n);
Gcell = num2cell(cell2mat([{coordinates{id}(:,1)},...
cellfun(@(x,y)[x(:,2:3);nan(m - y,2)],coordinates(:)',...
num2cell(n(:)'),'un',0)]),1);
T = table(Gcell{:},'v',k);

카테고리

도움말 센터File Exchange에서 Tables에 대해 자세히 알아보기

질문:

Coz
2017년 8월 1일

편집:

2017년 8월 2일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by