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 件のコメント

Alex Mcaulley
Alex Mcaulley 2019 年 5 月 8 日
What is the question? see this
Siddesh  chaudhary
Siddesh chaudhary 2019 年 5 月 8 日
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.
Adam Danz
Adam Danz 2019 年 5 月 8 日
編集済み: Adam Danz 2019 年 5 月 8 日
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).
Siddesh  chaudhary
Siddesh chaudhary 2019 年 5 月 8 日
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
Adam Danz
Adam Danz 2019 年 5 月 8 日
編集済み: Adam Danz 2019 年 5 月 8 日
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.
Geoff Hayes
Geoff Hayes 2019 年 5 月 8 日
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.
Adam Danz
Adam Danz 2019 年 5 月 8 日
編集済み: Adam Danz 2019 年 5 月 8 日
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.
Siddesh  chaudhary
Siddesh chaudhary 2019 年 5 月 8 日
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.
Siddesh  chaudhary
Siddesh chaudhary 2019 年 5 月 8 日
Thanks again @Geoff and @Adam, I made the changes as you suggested and it is working perfectly fine.
Thank you and Take care.

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeEvent Functions についてさらに検索

製品

リリース

R2016a

質問済み:

2019 年 5 月 8 日

コメント済み:

2019 年 5 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by