Effacer les filtres
Effacer les filtres

Comparing two srings using strcmpi

4 vues (au cours des 30 derniers jours)
Animesh
Animesh le 26 Déc 2013
Commenté : Image Analyst le 26 Déc 2013
I have stored the data of a uitable into a file dbt9.mat.. The first and second columns conntains the name and IdNo of an individual respectively. When I enter the name the corresponding IDno must be displayed in a editbox..
if true
% code
end
In=load('C:\Users\Animesh\Documents\MATLAB\dbt9.mat');%file name
ln=size(In.comp,1);% comp is the data in uitable dbt9..
for i=1:ln
nam=In.comp{i}
b=strcmpi(nam,name); name is the name I have entered
if b==1
break;
end
end
if b==0
set(handles.edit3,'String','NOT in db');
else
set(handles.edit3,'String',In.comp{ln+i});
end
The problem is that when my gui is opened at first it works perfectly fine but when I try with another name (keeping the gui open) it shows 'NOT in db'..and when i close the gui and open it once again and try with the same name the corresponding Idno is displayed.The problem arises in strcmpi .. Any reason why it is happening like this?? Can anyone help please? Thanks a lot in advance..

Réponse acceptée

Image Analyst
Image Analyst le 26 Déc 2013
Before the strcmpi put these lines:
name
nam
whos name
whos nam
What does it report in the command window? You might also find this useful: http://blogs.mathworks.com/videos/2012/07/03/debugging-in-matlab/
  8 commentaires
Animesh
Animesh le 26 Déc 2013
It worked..Thanks a lot for helping.
Image Analyst
Image Analyst le 26 Déc 2013
Please mark my answer as Accepted then. Thanks.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by