using conditional operators for string matching

J=im2uint8(im);
ocrResults = ocr(J)
recognizedText = ocrResults.Text;
TF=contains(recognizedText,'Axis Bank', 'IgnoreCase', true);
bboxes = locateText(ocrResults, 'Axis Bank', 'IgnoreCase', true);
Iocr = insertShape(J, 'FilledRectangle', bboxes);
figure;
imshow(Iocr);
disp('Axis Bank')
I am new to Matlab so I appreciate your patience regarding my noviceness.
I need to check if an OCR-ed string contains a substring and I need to check multiple substrings automatically. However I am unable to use any conditional operator as I do not understand how to use the logical output I am getting from
TF variable
Kindly assist me with this problem.
Thank you.

9 Comments

I am sorry, now that I have read my question, I understand its not clear...
My problem is as follows...
I want to identify the bank name using OCR, for which I am able to extract the text from the document however I need to match this entire string with the names of banks so as to perform further operations and for that I am using contains function. But when I am trying to use its logical output with a conditional operator I am getting an error ... and neither while, if or switch seems to be working.
I hope its clear now.
Thank you.
Could you provide the entire error message (copy-pasted)? Also, which line in your code is causing the error (you never use the TF variable as far as we can see).
I am not able to execute the conditional operators here this is the output I am getting apart from the different figures. 2019-05-08.png
I don't see an error message. Please try to explain the output you are getting and the output you want to get. Also, copy-pasted text is almost always better than screen shots of text.
Siddesh - you have your if/elseif block set up as
if TF == 1
% some code
elseif TF == 1
% some other code
end
The elseif block will never evaluate since it has the same condition as the first block. Perhaps you mean to do something like
if TF == 1
% some code
% TF = ...;
end
if TF == 1
% other code
end
Since in the if block you re-assign the value of TF.
Or perhaps
if TF
% some code
end
"if TF==1" is redundant. TF is a logical that is either true (1) or false (0).
@ Siddesh , select all of your code (cltr + a) and then auto-indent (ctrl + i). The indentation will help you to catch these types of issues.
Thanks @Geoff and @Adam I appreciate your suggestions. I am working on them and will ask for help in case I face any further issue.
Thank you.
Thanks again @Geoff and @Adam, I made the changes as you suggested and it is working perfectly fine.
Thank you and Take care.

Sign in to comment.

Answers (0)

Categories

Products

Release

R2016a

Community Treasure Hunt

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

Start Hunting!