MATLAB: Match numbers with letters

match numbers with letters

I need to find the name score of the names in a text file.
name point: David –> 4 1 22 9 4 = 4+1+22+9+4 = 40
Thanks for your help.

Best Answer

hello
this code does the trick :
ascii_value = uint32(yourstring); % convert your char / string into corresponding ASCII value
% let's converts ASCII values into values ranging from 1 to 26 (use offsets)
% uppercase letters
ind = find(ascii_value<91);
UL = ascii_value(ind) - 64;
% lowercase letters
ind = find(ascii_value>96);
LL = ascii_value(ind) - 96;
value = sum(UL) + sum(LL); %
Related Question