converting cell array full of characters to a string

4 次查看(过去 30 天)
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 个评论
Jan
Jan 2011-12-15
Or if the elements are scalar characters: cat(1, A{:})'

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by