converting cell array full of characters to a string

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 日

0 投票

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

Alex
Alex 2011 年 12 月 15 日
This still seems to display it vertically instead of horizontally
Sean de Wolski
Sean de Wolski 2011 年 12 月 15 日
The post transpose it:
char(cellfun(@transpose,A,'uni',false))'
Alex
Alex 2011 年 12 月 15 日
Thanks
Jan
Jan 2011 年 12 月 15 日
Or if the elements are scalar characters: cat(1, A{:})'

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by