Clear Filters
Clear Filters

converting cell array full of characters to a string

4 views (last 30 days)
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.

Accepted Answer

Sean de Wolski
Sean de Wolski on 15 Dec 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 Comments
Jan
Jan on 15 Dec 2011
Or if the elements are scalar characters: cat(1, A{:})'

Sign in to comment.

More Answers (0)

Categories

Find more on Data Type Conversion in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!