Combine two cell arrays containing string values into one.

10 ビュー (過去 30 日間)
Marc Jakobi
Marc Jakobi 2013 年 9 月 25 日
コメント済み: Johannes Rebling 2020 年 4 月 7 日
Hi.
I have two cell arrays that look something like this:
A = {'1.'; '2.'; '3.'; '4.', '5.'};
B = {'A'; 'B'; 'C'; 'D'; 'E'};
Both are of the same length.
I want to combine them into a third cell array that looks like this:
C = {'1. A'; '2. B'; '3. C'; '4. D'; '5. E'};
How can I do this?
Thanks!

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 9 月 25 日
編集済み: Azzi Abdelmalek 2013 年 9 月 25 日
A = {'1.'; '2.'; '3.'; '4.'; '5.'};
B = {'A'; 'B'; 'C'; 'D'; 'E'};
C=cellfun(@(x,y) [x ' ' y],A,B,'un',0)
  3 件のコメント
Katharina
Katharina 2020 年 3 月 10 日
Perfect, Thanks!
Johannes Rebling
Johannes Rebling 2020 年 4 月 7 日
For those like me, wondering what the 'un',0 at the end of cellfun means, it's the same as 'UniformOutput',true. Thanks for the solution!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by