How to merge cells together?

16 visualizzazioni (ultimi 30 giorni)
andrew
andrew il 6 Mag 2014
Risposto: Jos (10584) il 13 Mag 2014
How do I merge cells together and separate each cell with a ';'?

Risposta accettata

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

Accedi per commentare.

Più risposte (1)

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

Categorie

Scopri di più su Cell Arrays in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by