MATLAB: Comparing two srings using strcmpi

comparestrcmpi

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..

Best Answer

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/