Convert an array of letters into numbers
조회 수: 43 (최근 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!