MATLAB: Convert alphabet to coresponding number by using ASCII

asciiconvert character to number

I have question, how to convert alphabet in lowercase to coresponding number by using ASCII. Such as a=1,b=2,c=3…

Best Answer

Like this
char2num = @(c) char(c)-96;
Example
>> char2num('a')
ans =
1
>> char2num('b')
ans =
2
>> char2num('z')
ans =
26