How can I turn a 1*1 cell into a cell array?

4 ビュー (過去 30 日間)
marvellous
marvellous 2024 年 8 月 19 日
コメント済み: marvellous 2024 年 8 月 21 日
For example, what is the easiest way to turn a 1*1 cell 'a b c d e' into a cell array {'a'} {'b'} {'c'} {'d'} {'e'}? Please! Anyone can help me?

採用された回答

Sameer
Sameer 2024 年 8 月 19 日
編集済み: Sameer 2024 年 8 月 19 日
Hi
To split a 1x1 cell containing a string and convert the result into a cell array, you can utilize the "strsplit" function.
originalCell = {'a b c d e'};
splitArray = strsplit(originalCell{1});
disp(splitArray);
Hope this helps!
  3 件のコメント
Walter Roberson
Walter Roberson 2024 年 8 月 20 日
Another way:
originalCell = {'a b c d e'};
regexp(originalCell{1}, ' +', 'split')
ans = 1x5 cell array
{'a'} {'b'} {'c'} {'d'} {'e'}
marvellous
marvellous 2024 年 8 月 21 日
Oh, I didn't expect it, thanks!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by