Convert a string array to a cell array of strings

Starting with a cell array of strings,
>> C={'person','woman','man','camera','TV'};
I know that it is possible to convert to a string array,
>> S = string(C)
S =
1×5 string array
"person" "woman" "man" "camera" "TV"
I am wondering, however, whether there is a command to do the reverse conversion. I can make my own as follows,
>> C=arrayfun(@(s)char(s),S,'uni',0)
C =
1×5 cell array
{'person'} {'woman'} {'man'} {'camera'} {'TV'}
However, I am wondering if there is a native Matlab command for doing this that I have overlooked.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 14 de Sept. de 2020
cellstr(S)

2 comentarios

Matt J
Matt J el 14 de Sept. de 2020
Ah, good. Counter-intuitively named though, IMO.
It could be claimed that it is natural because it takes string ('str') and produces a cell ('cell')
... But I wouldn't claim that.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 14 de Sept. de 2020

Comentada:

el 14 de Sept. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by