combine celle array of cell array vertically

8 ビュー (過去 30 日間)
Mederic Mainson
Mederic Mainson 2016 年 9 月 19 日
回答済み: Mederic Mainson 2016 年 9 月 19 日
Hi, I have a cell arrays of cell array 'ABC'. Rows of ABC represent data from different experiment. Columns of ABC represent different type of measurement for experiments. for example columns 1 is the time stamp of each sample. at the moment i have a m*n cell array of cell array. I want to concatenate ABC so i end up with a cell array of cell array with a dimension of 1*n. Any ideas? I used
vertcat(ABC{:})
but it concatenates the all data into 1 colunm, i want to keep my colunms... Cheers
Screen capture:

採用された回答

Guillaume
Guillaume 2016 年 9 月 19 日
編集済み: Guillaume 2016 年 9 月 19 日
This
cellfun(@(col) vertcat(col{:}), num2cell(ABC, 1), 'UniformOutput', false)
or
arrayfun(@(col) vertcat(ABC{:, col}), 1:size(ABC, 2), 'UniformOutput', false)
will do what you ask. The 2nd one may be faster.

その他の回答 (2 件)

KSSV
KSSV 2016 年 9 月 19 日
You can use reshape to convert your mxn cell array into any desired size. As you want to convert it to column. Use:
A = reshape(ABC,[],1) ; % 1 specifies the column, [] matlab decides the number of rows (=m*n)

Mederic Mainson
Mederic Mainson 2016 年 9 月 19 日
Thanks both of you guys, it both solution work, but i prefer Guillaume's one, it takes only 1 lines ;) cheers Medie

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by