当我在 MATLAB 中运行我的代码时,我总是收到此错误消息。我想做模板匹配来识别一个字符。
??? Operands to the || and && operators must be convertible to logical scalar values.
Error in ==> readLetter at 17
if vd==1 || vd==2
我的代码是
load NewTemplates % Loads the templates of characters in the memory.
gambar = imresize(gambar,[42 24]); % Resize the input image
comp = [];
for n = 1 : length(NewTemplates)
sem = corr2(NewTemplates{1,n}, gambar); % Correlation with every image in the template for best matching.
comp = [comp sem]; % Record the value of correlation for each template's character.
end
vd = find(comp == max(comp)); % Find index of highest matched character.
% According to the index assign to 'letter'.
if vd==1 || vd==2
letter='A';
如何解决?