converting cell array full of characters to a string

조회 수: 7 (최근 30일)
Alex
Alex 2011년 12월 15일
This is probably easy but I can't figure it out. I have a cell array where each entry is a character. I want to convert this cell array to a string because the characters in the cell array form a sentence. I tried char(array) which sort of works except it displays the string vertically instead of horizontally.

채택된 답변

Sean de Wolski
Sean de Wolski 2011년 12월 15일
How about:
A = {'the';'quick';'brown';'fox'}
char(A)
or
char(cellfun(@transpose,A,'uni',false))
etc depending on how you want to convert it.
  댓글 수: 4
Alex
Alex 2011년 12월 15일
Thanks
Jan
Jan 2011년 12월 15일
Or if the elements are scalar characters: cat(1, A{:})'

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by