How can I turn a 1*1 cell into a cell array?
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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?
0 commentaires
Réponse acceptée
Sameer
le 19 Août 2024
Modifié(e) : Sameer
le 19 Août 2024
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 commentaires
Walter Roberson
le 20 Août 2024
Another way:
originalCell = {'a b c d e'};
regexp(originalCell{1}, ' +', 'split')
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!