How to merge cells together?

12 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by