Hi, I coded a program that can can take an image of a lisence palte and output it's numbers and letters. Now I'm trying to set up a way for the user to enter the correct lettes/numbers of the lisence plate to see if it matches with the letters and numbers generated by MatLab I'm just not sure how. I'm not sure how the user can input a line of both numbers and letters as input. For reference noPlate is the name of the numberplate generated by matlab.
x = input('What is the correct value of the lisence plate? ')
if (x==noPlate)
output('Nice')
else
output('The entered value does not match MatLab. Would you like to try again? (Y/N)')
end
Thanks, any help will be appreciated!

댓글 수: 1

Is noPlate a character array (exampple 'F4RE9')? If not it would be easier to convert noPlate to a character array.
if isequal(x,noPlate) %should use isequal
You could convert 'F4RE9' to both letters and numbers in a cell array
x= 'F4RE9';
a=mat2cell(x',ones(size(x')));
for k=1:length(a)
if a{k}>='0'&&a{k}<='9'
a{k}=str2double(a{k});
end
end
%now a is a cell array of letters and numbers and isequal will still work
%as long as noPlate is in same cell array

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

답변 (1개)

Abolfazl Chaman Motlagh
Abolfazl Chaman Motlagh 2022년 3월 3일

1 개 추천

if the plate (variable) could have both number and latters, deal with them like string. for getting input as string you need extra option 's' . for comparing two string use strcmp.
User_input = input('What is the correct value of the lisence plate? ','s');
if strcmp(User_input,noPlate)
output('Nice')
else
output('The entered value does not match MatLab. Would you like to try again? (Y/N)')
end
noPlate should be string too. like:
noPlate = '123J45';

카테고리

도움말 센터 및 File Exchange에서 Convert Image Type에 대해 자세히 알아보기

제품

릴리스

R2021a

질문:

2022년 3월 3일

댓글:

2022년 3월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by