How to split letters in a word into an array
270 views (last 30 days)
Show older comments
Ex: In the word 'HELLO', extract the letters 'H' 'E' 'L' 'L' 'O'
Jan on 1 Jul 2013
The string 'Hello' consists of single characters already:
str = 'Hello';
for k = 1:length(str)
So please explain the wanted type and dimensions of the output. 'H' 'E' 'L' 'L' 'O' is not clear enough.
Adam Danz on 25 May 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.
More Answers (2)
Tom on 1 Jul 2013
Edited: Tom on 1 Jul 2013
str = 'HELLO';
Octa on 2 Jul 2013
If you want to extract the letters, simply extract in this way
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!