converting cell array full of characters to a string

14 vues (au cours des 30 derniers jours)
Alex
Alex le 15 Déc 2011
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.

Réponse acceptée

Sean de Wolski
Sean de Wolski le 15 Déc 2011
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 commentaires
Alex
Alex le 15 Déc 2011
Thanks
Jan
Jan le 15 Déc 2011
Or if the elements are scalar characters: cat(1, A{:})'

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by