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

조회 수: 2 (최근 30일)
Sakunrat Jaejaima
Sakunrat Jaejaima 2015년 7월 1일
댓글: annmaria 2015년 7월 13일
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

채택된 답변

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

추가 답변 (1개)

Stephen23
Stephen23 2015년 7월 1일
편집: Stephen23 2015년 7월 13일
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
Stephen23
Stephen23 2015년 7월 13일
My pleasure. You can also accept answers that best help to resolve your question.
annmaria
annmaria 2015년 7월 13일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by