You could put a counter that you iterate within the loop:
locked_flag = false
counter = 0
while (x ~= 1111)
if (x == password)
uiwait( msgbox('Welcome!') );
break;
else
uiwait( errordlg('Try Again!!') );
counter = counter + 1
if (counter == 3)
locked_flag = true;
%show 'locked' dialog of some kind here
break;
end
X = inputdlg('Please enter your password');
x = str2double ( X{1,1} );
end
end
%can now check if locked_flag true to start unlock logic or other...
EDIT: Yes I'd only posted a snippet of your code, you need the logic above it, as such, sorry if that wasn't clear:
X = inputdlg ('Please enter your password');
x = str2double (X {1,1} );
password = 1111; %whatever
if (x == password)
uiwait( msgbox('Welcome!') );
else
locked_flag = false
counter = 1
while (x ~= 1111)
if (x == password)
uiwait( msgbox('Welcome!') );
break;
else
uiwait( errordlg('Try Again!!') );
counter = counter + 1
if (counter == 3)
locked_flag = true;
%show 'locked' dialog of some kind here
break;
end
X = inputdlg('Please enter your password');
x = str2double ( X{1,1} );
end
end
end
%can now check if locked_flag true to start unlock logic or other...