how to convert a cell array to a string array

137 ビュー (過去 30 日間)
梓昂 郑
梓昂 郑 2022 年 1 月 10 日
編集済み: Stephen23 2022 年 1 月 10 日
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?
  1 件のコメント
Stephen23
Stephen23 2022 年 1 月 10 日
編集済み: Stephen23 2022 年 1 月 10 日
"I have a cell array of 2048*1,each cell countains a string element..."
Highly unusual and not recommended: "Avoid using cell arrays of strings. When you use cell arrays, you give up the performance advantages that come from using string arrays."
The best solution is to avoid creating this cell array in the first place, and instead store the data in a string array (or as a cell array of character vectors) right from the start. How was this cell array created?

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

回答 (1 件)

Yusuf Suer Erdem
Yusuf Suer Erdem 2022 年 1 月 10 日
S = {'Hello',' ','world',' ','i',' ','am',' ','here'}
ss = [S{:}]
  2 件のコメント
Yusuf Suer Erdem
Yusuf Suer Erdem 2022 年 1 月 10 日
hi @Stephen what about this function?
str = convertCharsToStrings(chr)

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

カテゴリ

Find more on Characters and Strings 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!

Translated by