Convert Letter to Number [duplicate]

2019-03-04 04:41发布

问题:

This question already has an answer here:

  • How to compute word scores in Scrabble using MATLAB 3 answers

I'm new to matlab ... I simply would like to convert letter to numbers such that:

A=1
B=2
C=3

all my numbers are capital case. Off course, I could define constant for each char, but is there a shorter way?

Thanks!

回答1:

See the char function. You can give it an integer argument.

http://www.mathworks.com/help/matlab/ref/char.html