MATLAB Answers

Why it is showing error?

5 views (last 30 days)
Kartikey Rai
Kartikey Rai on 11 Oct 2019
Answered: Geoff Hayes on 11 Oct 2019
function letter = readLetter(snap)
load NewTemplates
snap = imresize(snap,[42 24]);
rec = [ ];
for n = 1:length(NewTemplates)
cor = corr2(NewTemplates{1,n},snap);
rec = [rec cor];
end
ind = find(rec == max(rec));
display(find(rec == max(rec)));
% Alphabets listings.
if ind == 1 || ind == 2
letter = 'A';
elseif ind == 3 || ind == 4
letter = 'B';
elseif ind == 5
letter = 'C';
elseif ind == 6 || ind == 7
letter = 'D';
elseif ind == 8
letter = 'E';
elseif ind == 9
letter = 'F';
elseif ind == 10
letter = 'G';
elseif ind == 11
letter = 'H';
elseif ind == 12
letter = 'I';
elseif ind == 13
letter = 'J';
elseif ind == 14
letter = 'K';
elseif ind == 15
letter = 'L';
elseif ind == 16
letter = 'M';
elseif ind == 17
letter = 'N';
elseif ind == 18 || ind == 19
letter = 'O';
elseif ind == 20 || ind == 21
letter = 'P';
elseif ind == 22 || ind == 23
letter = 'Q';
elseif ind == 24 || ind == 25
letter = 'R';
elseif ind == 26
letter = 'S';
elseif ind == 27
letter = 'T';
elseif ind == 28
letter = 'U';
elseif ind == 29
letter = 'V';
elseif ind == 30
letter = 'W';
elseif ind == 31
letter = 'X';
elseif ind == 32
letter = 'Y';
elseif ind == 33
letter = 'Z';
% Numerals listings.
elseif ind == 34
letter = '1';
elseif ind == 35
letter = '2';
elseif ind == 36
letter = '3';
elseif ind == 37 || ind == 38
letter = '4';
elseif ind == 39
letter = '5';
elseif ind == 40 || ind == 41 || ind == 42
letter = '6';
elseif ind == 43
letter = '7';
elseif ind == 44 || ind == 45
letter = '8';
elseif ind == 46 || ind == 47 || ind == 48
letter = '9';
else
letter = '0';
end
end
Screenshot (39).png

  0 Comments

Sign in to comment.

Answers (1)

Geoff Hayes
Geoff Hayes on 11 Oct 2019
Kartikey - there appears to be a hidden character at your line 70 which is the "blank" line in
% Numerals listings.
elseif ind == 34
If, on Linux, I do a cat -t readLetter.m, I see a question mark at the blank line
elseif ind == 33
letter = 'Z';
?
% Numerals listings.
elseif ind == 34
Just delete the blank line and the line with the comment to ensure that this special character is removed.

  0 Comments

Sign in to comment.

Sign in to answer this question.