Combine 2 Cell Matrices into One

1 回表示 (過去 30 日間)
Ruger28
Ruger28 2020 年 5 月 6 日
コメント済み: Star Strider 2020 年 5 月 6 日
Hello,
Im trying to combine data from two matrices into one. An example:
A = {'A','B','C';'A','B','C'};
B = {'1','1','1';'2','2','2'};
and I want C to be:
C = {'A1','B1','C1';'A2','B2','C2'};
I feel like this is trivial, and I am definitely missing something. Any help would be greatly appreciated.

採用された回答

Star Strider
Star Strider 2020 年 5 月 6 日
Try this:
A = {'A','B','C';'A','B','C'};
B = {'1','1','1';'2','2','2'};
C = cellfun(@(x,y)[x,y], A, B, 'Uni',0)
producing:
C =
2×3 cell array
{'A1'} {'B1'} {'C1'}
{'A2'} {'B2'} {'C2'}
.
  2 件のコメント
Ruger28
Ruger28 2020 年 5 月 6 日
Thank you very much! I was definitely going the wrong direction. I apprecaite the help!
Star Strider
Star Strider 2020 年 5 月 6 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by