당신은 루프 내에서 반복 카운터 넣을 수 :
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...
편집 : 예 난 단지 코드의 조각을 게시 것을, 당신은, 위의 논리가 필요합니다 같은, 그 경우 죄송는 분명하지 않다 :
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...
대신 동안의 리터에서'x'를 사용하는, 아주 가까이있어 oop, 계산하려면 변수를 사용하십시오. 다음과 같이'failed_count = 0'으로 초기화하고 while (failed_count