Convert Cell to String
조회 수: 6 (최근 30일)
이전 댓글 표시
I have a cell array:
x = {'red' 'blue' 'green'}
I need to convert it to a string (looking for another way besides char). So the output would be:
red
blue
green
Thanks, Amanda
댓글 수: 1
Walter Roberson
2013년 5월 2일
A single string with something (like a newline) between the parts? Or one string per cell entry? Is this for storing or for displaying? Could you indicate why using "char" is not desirable ?
채택된 답변
Cedric
2013년 5월 2일
You could use something like:
s = sprintf('%s\n', x{:})
댓글 수: 3
Walter Roberson
2013년 5월 2일
Note that this would have newline characters between the parts. I am not sure that is what the poster wants.
추가 답변 (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!