convert alphabet to coresponding number by using ASCII
조회 수: 5 (최근 30일)
이전 댓글 표시
I have question, how to convert alphabet in lowercase to coresponding number by using ASCII. Such as a=1,b=2,c=3...
댓글 수: 0
채택된 답변
Ameer Hamza
2020년 5월 25일
Like this
char2num = @(c) char(c)-96;
Example
>> char2num('a')
ans =
1
>> char2num('b')
ans =
2
>> char2num('z')
ans =
26
댓글 수: 0
추가 답변 (1개)
Walter Roberson
2020년 5월 25일
UpperToLower = @(c) char(c-'A'+'a')
Or if you are daring,
UpperToLower = @(c) char(c+32);
댓글 수: 0
참고 항목
카테고리
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!