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!