String array of the letters of the alphabet
조회 수: 38 (최근 30일)
이전 댓글 표시
Is there a compact way to generate a string array with the letters of the English alphabet?
alphabet = ["a","b", .., "z"]
댓글 수: 0
추가 답변 (1개)
John D'Errico
2023년 2월 10일
alf = 'a':'z'
It also works for caps.
ALF = 'A':'Z'
댓글 수: 2
John D'Errico
2023년 2월 10일
The obvious is:
alf = string('a':'z')
That makes a string array, but you wanted a set of scalar string arrays. So then I see that this will create the desired string array.
string({'a' 'b'})
And that means you can use mat2cell.
string(mat2cell('a':'z',1,ones(1,26)))
It feels a little kludgy. But it works. There may be a better way. If so, I'll probably think of it as soon as I click on submit.
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!