How to split letters in a word into an array
36 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ex: In the word 'HELLO', extract the letters 'H' 'E' 'L' 'L' 'O'
0 comentarios
Respuesta aceptada
Jan
el 1 de Jul. de 2013
The string 'Hello' consists of single characters already:
str = 'Hello';
for k = 1:length(str)
disp(str(k))
end
So please explain the wanted type and dimensions of the output. 'H' 'E' 'L' 'L' 'O' is not clear enough.
4 comentarios
Adam Danz
el 25 de Mayo de 2021
☝ num2cell is the best solution. In case str is of class string
c = num2cell(char(str));
This works when str is a character array or a string.
Ver también
Categorías
Más información sobre Characters and Strings en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!