Effacer les filtres
Effacer les filtres

cell array to string array

4 vues (au cours des 30 derniers jours)
Ido Gross
Ido Gross le 2 Avr 2020
Commenté : simon xi le 8 Juil 2023
Hi
I have a cell array consisting of strings. I would like to convert it to an array with one word in each cell.
for example, the cell array: "Hello B
Hi A
Where is D?
and I need: Hello
B
Hi etc.
TIA
  1 commentaire
simon xi
simon xi le 8 Juil 2023
b=string(a)

Connectez-vous pour commenter.

Réponse acceptée

Ameer Hamza
Ameer Hamza le 2 Avr 2020
Modifié(e) : Ameer Hamza le 2 Avr 2020
Something like this
A = {'Hello B Hi A Where is D?'};
B = strsplit(A{:}, ' ')';
Result:
B =
7×1 cell array
{'Hello'}
{'B' }
{'Hi' }
{'A' }
{'Where'}
{'is' }
{'D?' }
  6 commentaires
Ido Gross
Ido Gross le 2 Avr 2020
Amazing! thank you so much!
Ameer Hamza
Ameer Hamza le 2 Avr 2020
Glad to be of help.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings 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!

Translated by