How to covert a cell to multiple line string?
조회 수: 9 (최근 30일)
이전 댓글 표시
I have a cell with one coloumn and varing number of rows. The cell contains alpha-numeric string. I want to convert this cell into a multiple line string with each cell content as one line of the string.
How can this be acheived ?
댓글 수: 1
Jan
2016년 9월 26일
Cells are arrays. Therefore all columns have the same number of rows. I assume, the contents of the cell elements are char vectors with a different number of clumns.
채택된 답변
Jan
2016년 9월 26일
If you use CHAR you get a CHAR matrix padded with blanks on the right side. You can get "multi-line" also by inserting line breaks:
CellString = {'some'; 'strings'; 'to'; 'convert'; 'to'; 'a'; 'char'; 'array'}
CharString = sprintf('%s\n', CellString{:});
추가 답변 (1개)
Guillaume
2016년 9월 26일
Use char:
cellarrayofstring = {'some'; 'strings'; 'to'; 'convert'; 'to'; 'a'; 'char'; 'array'}
chararrayofstring = char(cellarrayofstring)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!