Convert an array of letters into numbers
57 次查看(过去 30 天)
显示 更早的评论
I would like to convert an array of letters into numbers. Based on this code:
Alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
numbers = [3,6,12,1,1,3]
letters = Alphabet(numbers)
I would like to make the reverse of this. I mean I want to find eg 'HELLO' to which numbers correspont based on the above code.
回答(2 个)
Walter Roberson
2021-1-30
Alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
[~, HelloNumbers] = ismember('HELLO', Alphabet)
Map(Alphabet) = 1:length(Alphabet);
Map('HELLO')
5 个评论
Stephen23
2021-1-31
"Is there a way to set A equal to Á and À? I mean in order to not take into account accents?"
Yes, two approaches were given to you in answers to your earlier question (which you then deleted):
Walter Roberson
2021-1-31
Alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZÀÈÌÒÙÁÉÍÓÚÄËÏÖŸ';
Map(Alphabet(1:26)) = 1:26;
Map(Alphabet(27:end)) = Map('AEIOUAEIOUAEIOY');
Map('HÈLLÖ')
另请参阅
类别
在 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!