how to convert a cell array to a string array

233 ビュー (過去 30 日間)
梓昂 郑
梓昂 郑 2022 年 1 月 10 日
コメント済み: Walter Roberson 2023 年 5 月 13 日
I have a cell array of 2048*1,each cell countains a string element, and i want to convert it into a string array (so that i could make it one hot coded)
how cloud i slove it?
  2 件のコメント
Kelvin Prosyk
Kelvin Prosyk 2023 年 5 月 13 日
The OP is valid. There could be situations where it is unavoidable. For example, reading in mixed data from an Excel spreadsheet using the readcell function.

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

回答 (1 件)

Yusuf Suer Erdem
Yusuf Suer Erdem 2022 年 1 月 10 日
S = {'Hello',' ','world',' ','i',' ','am',' ','here'}
ss = [S{:}]
  4 件のコメント
Walter Roberson
Walter Roberson 2023 年 5 月 13 日
S = {"Hello"," ","world"," ","i"," ","am"," ","here"}.'
S = 9×1 cell array
{["Hello"]} {[" " ]} {["world"]} {[" " ]} {["i" ]} {[" " ]} {["am" ]} {[" " ]} {["here" ]}
SA = reshape([S{:}], size(S))
SA = 9×1 string array
"Hello" " " "world" " " "i" " " "am" " " "here"

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

カテゴリ

Help Center および 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