How to encode alphabets using tables

22 views (last 30 days)
Hi I want to encode the word "CONGRATULATIONS" using upper case letters.For this I have the table
A 0
B 1
C 2
D 3 ......and so on.
I dont know how to relate this type of mapping in matlab.
Alphabets={'A';'B';'C';'D';'E';'F';'G';'H';'I';'J';'K';'L';'M';'N';'O';'P';'Q';'R';'S';'T';'U';'V';'W';'X';'Y';'Z';'null space'};
numeric_values=[0;1;2 ;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26];

Accepted Answer

R.G. on 1 Sep 2019
Edited: R.G. on 1 Sep 2019
Hello! Check following code. I used char(65:90) to create A-Z sequence, and Map container to map symbols into codes.
symbols = [num2cell(char(65:90)) 'space'];
codes = 0:26;
dictionary = containers.Map(symbols, codes);
word = num2cell('CONGRATULATIONS');
encoded_word = cell(size(word));
for i = 1:length(word)
encoded_word{i} = dictionary(word{i});
sadiqa ilyas
sadiqa ilyas on 3 Sep 2019
Thanks. Its really a smart way for mapping.

Sign in to comment.

More Answers (1)

Fauzi Kadir
Fauzi Kadir on 18 Jun 2021
hello.. how to create matlab code for letter M and F using robotic arm [rvc toolbox Matlab] ?????
  1 Comment
Walter Roberson
Walter Roberson on 18 Jun 2021
Hmmm, so the robotic arm is to.... type on a keyboard.... to input MATLAB code that... looks up M and F in a table to determine the encodings 12 and 4 ???
The robotic arm is to operate a CNC to produce a device that self-assembles into something that can type on a keyboard to enter MATLAB code ... ???

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by