How to merge cells together?

45 views (last 30 days)
andrew on 6 May 2014
Answered: Jos (10584) on 13 May 2014
How do I merge cells together and separate each cell with a ';'?

Accepted Answer

José-Luis on 6 May 2014
Edited: José-Luis on 13 May 2014
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{:}];
José-Luis on 13 May 2014
A=[ {'1'},{'1'},{'1'},{'1'},{'0'},{'1'},{'0'},{'1'}];
unique_cell = {sprintf('%s;',A{:})};
Please accept an answer if it helped you.

Sign in to comment.

More Answers (1)

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


Find more on Characters and Strings in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!