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!