converting characters to a number string
5 次查看(过去 30 天)
显示 更早的评论
I'm trying to decipher a text file full of lowercase characters. First I have to convert the characters to 27 numbers (1 for each letter and 27=space) using "double". Can you guys help me code:
1. a "function" which converts any text file with 27 unique characters (including space) into a string of 27 unique numbers? I have to use "double" to convert to ASCII first, and then convert the 26 lowercase letters and space into 1:27
ex: function('hello')=[8 5 12 12 15]
2. a "function" that reverses the process, using "char"?
ex: functioninverse([8 5 12 12 15])=hello
0 个评论
采纳的回答
Walter Roberson
2015-10-4
[~, idx] = ismember( tolower(TheTextString), ['a' : 'z', ' ']);
result = double(idx);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!