How can to concatenate data from each column of a cell array into a row?
조회 수: 1 (최근 30일)
이전 댓글 표시
I have a 1x13 cell array where each column has a 1200x2 array.
I need to reorganize it to a 1x15600 with a 2x1 array in each column. In other words, 1x15600 cell array of 2x1 vectors representing two values over 1200 timesteps to use as a InputSeries of a Neural Network.
Visually, I have:
c1 c2 … c13 -> column of cell array
-------------------------------------------------------
1 1.2 1.3 1.4 … 1.25 1.26
2 2.2 2.3 2.4 … 2.25 2.26
3 3.3 3.3 3.4 … 3.25 3.26
.
.
.
1200 1200.2 1200.3 1200.4 … 1200.25 1200.26
What I need:
c1 c2 … c1200 c1201 c1202 … c15600 -> number of columns of new cell array
------------------------------------------------------------------------
1 2 … 1200 1.3 2.3 … 1200.25
1.2 2.2 … 1200.2 1.4 2.4 … 1200.26
I tried to transpose the original cell array to have a 1x13 w/2x1200 and then concatenate each column but my code never worked as I wanted. Some commands I used: transpose, cat, reshape, arrayfun.
Thank you, Erika
댓글 수: 0
채택된 답변
James Tursa
2016년 10월 26일
편집: James Tursa
2016년 10월 26일
Like this?
C = your cell array
result = mat2cell(cell2mat(cellfun(@transpose,C,'uni',false)),2,ones(1,15600));
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!