How to combine rows of cell array into corresponding single cell

36 ビュー (過去 30 日間)
Maii 2020 年 3 月 26 日
コメント済み: Maii 2020 年 3 月 26 日
I want to combine rows of a cell array into a single cell. Such that a cell array of dimension 5*4 comes as a cell array of 5*1 where each cell is a cell array of 1*4. I want to remove the for loop, since my cell matrices are huge.
For example:
I can use the following for loop to get the result. But is it possible without a for loop?
for i=1:1:size(a,1)
c{i,1}={a(i) b(i)};
result c={{123, 'xyz'};{'xyz', 123};{'abc', 243};{'asd', 'zxy'};{123, 123}};
Thank you!


Bhaskar R
Bhaskar R 2020 年 3 月 26 日
c = cellfun(@(x, y){x,y}, a,b,'UniformOutput',false)

その他の回答 (0 件)


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

Community Treasure Hunt

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

Start Hunting!

Translated by