How to split letters in a word into an array
조회 수: 81 (최근 30일)
이전 댓글 표시
채택된 답변
Jan
2013년 7월 1일
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
Adam Danz
2021년 5월 25일
☝ 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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!