How to merge cells together?

7 ビュー (過去 30 日間)
andrew
andrew 2014 年 5 月 6 日
回答済み: Jos (10584) 2014 年 5 月 13 日
How do I merge cells together and separate each cell with a ';'?

採用された回答

José-Luis
José-Luis 2014 年 5 月 6 日
編集済み: José-Luis 2014 年 5 月 13 日
Two alternatives, since I am not exactly sure what you want.
a = num2cell(randi(10,10,10));
your_mat = cell2mat(a);
your_mat_alt = [a{:}];
  2 件のコメント
andrew
andrew 2014 年 5 月 13 日
so i currently have apple.doc, apple.xlsx, apple.csv, banana.doc, banana.xlsx ,etc. in seperate columns. the output should be ['apple.doc;''apple.xslx;' 'banana.doc;' 'banana.xlsx;'] all in one cell
José-Luis
José-Luis 2014 年 5 月 13 日
A=[ {'1'},{'1'},{'1'},{'1'},{'0'},{'1'},{'0'},{'1'}];
unique_cell = {sprintf('%s;',A{:})};
Please accept an answer if it helped you.

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

その他の回答 (1 件)

Jos (10584)
Jos (10584) 2014 年 5 月 13 日
Another option using STRCAT
A = {'apple.doc', 'apple.xlsx', 'apple.csv', 'banana.doc', 'banana.xlsx'}
B = strcat(A,';')
C = [B{:}]

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by