I want to convert the numbers in the matrix as the letter .

2 views (last 30 days)
Hello . I do code but it runs off a single character , I want it to run all out. What to do?
B=input('Enter martrix:');
switch B(1,1)
case{1}
disp('A');
case{2}
disp('B');
case{3}
disp('C');
case{4}
disp('D');
case{5}
disp('E');
case{6}
disp('F');
case{7}
disp('G');
case{8}
disp('H');
case{9}
disp('I');
case{10}
disp('J');
case{11}
disp('K');
case{12}
disp('L');
case{13}
disp('M');
case{14}
disp('N');
case{15}
disp('O');
case{16}
disp('P');
case{17}
disp('Q');
case{18}
disp('R');
case{19}
disp('S');
case{20}
disp('T');
case{21}
disp('U');
case{22}
disp('V');
case{23}
disp('W');
case{24}
disp('X');
case{25}
disp('Y');
case{26}
disp('Z');
case{27}
disp('.');
case{28}
disp('?');
otherwise
disp(' ');
end

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 1 Jul 2015
b=input('enter a number');
str=['A':'Z' '.?']
if ismember(b,1:28)
out=str(b)
disp(out)
else
disp(' ')
end

More Answers (1)

Stephen23
Stephen23 on 1 Jul 2015
Edited: Stephen23 on 13 Jul 2015
To perform this for all elements of the input array you should learn how to write vectorized code, which is much neater, faster and less buggy, and also learn how indexing works.
B = input('Enter a matrix: ');
B(B<1 | B>29) = 29;
V = ['A':'Z','.? '];
V(B)
When this code is run it produces this in the command line:
Enter a matrix: [1,2,0,3,27;4,28,5,29,6]
ans =
AB C.
D?E F
  3 Comments
Stephen23
Stephen23 on 13 Jul 2015
My pleasure. You can also accept answers that best help to resolve your question.
annmaria
annmaria on 13 Jul 2015
If i have two folders with letters .First One have different fond and orientation. i want to match the letters with the other folder and display the letters in the second folder. Is it possible. Can anyone please help me.

Sign in to comment.

Categories

Find more on Mathematics in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!