Convert Cell to String

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 件のコメント

Walter Roberson
Walter Roberson 2013 年 5 月 2 日
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 ?

サインインしてコメントする。

 採用された回答

Cedric
Cedric 2013 年 5 月 2 日

1 投票

You could use something like:
s = sprintf('%s\n', x{:})

3 件のコメント

Amanda
Amanda 2013 年 5 月 2 日
Thanks a lot again.
Walter Roberson
Walter Roberson 2013 年 5 月 2 日
Note that this would have newline characters between the parts. I am not sure that is what the poster wants.
Cedric
Cedric 2013 年 5 月 2 日
編集済み: Cedric 2013 年 5 月 2 日
I assumed newline (and e.g. output to file) because of the way the question was formulated/structured, but this is a good point.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCharacters and Strings についてさらに検索

質問済み:

2013 年 5 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by