Convert Cell to String

9 views (last 30 days)
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 Comment
Walter Roberson
Walter Roberson on 2 May 2013
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 ?

Sign in to comment.

Accepted Answer

Cedric Wannaz
Cedric Wannaz on 2 May 2013
You could use something like:
s = sprintf('%s\n', x{:})
  3 Comments
Cedric Wannaz
Cedric Wannaz on 2 May 2013
I assumed newline (and e.g. output to file) because of the way the question was formulated/structured, but this is a good point.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!