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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by