cell array to string array

3 visualizaciones (últimos 30 días)
Ido Gross
Ido Gross el 2 de Abr. de 2020
Comentada: simon xi el 8 de Jul. de 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

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 2 de Abr. de 2020
Editada: Ameer Hamza el 2 de Abr. de 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 comentarios
Ido Gross
Ido Gross el 2 de Abr. de 2020
Amazing! thank you so much!
Ameer Hamza
Ameer Hamza el 2 de Abr. de 2020
Glad to be of help.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by