Azzera filtri
Azzera filtri

cell array to string array

4 visualizzazioni (ultimi 30 giorni)
Ido Gross
Ido Gross il 2 Apr 2020
Commentato: simon xi il 8 Lug 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

Risposta accettata

Ameer Hamza
Ameer Hamza il 2 Apr 2020
Modificato: Ameer Hamza il 2 Apr 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 Commenti
Ido Gross
Ido Gross il 2 Apr 2020
Amazing! thank you so much!
Ameer Hamza
Ameer Hamza il 2 Apr 2020
Glad to be of help.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Characters and Strings in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by