Error on user input/while statement

조회 수: 1 (최근 30일)
Ryan Bowman
Ryan Bowman 2018년 11월 13일
다시 열림: KSSV 2018년 11월 13일
I'm trying to ask the user for an input which will be somewhere between 0 and 10. If the user doesn't enter a number between 0 and 10 then it should come up with a warning message and then allow the user to re-enter a value but I'm getting an error on "Involvement_Response = input...." I don't understand why. Any help?
Involvement_Grade = [0];
InvolvementOK = false;
while ~InvolvementOK;
Involvement_Prompt = input('How many involvement points do you expect to recieve? %d?\n (Enter a number between 0 and 10, then press enter); ');
Involvement_Response = input(Involvement_Prompt);
if Involvement_Response < 0
uiwait(warndlg('Your input is too low'));
elseif Involvement_Response > 10
uiwait(warndlg('Your input is too high'));
else
Involvement_Grade = Involvement_Response;
InvolvementOK = true
end
end
  댓글 수: 1
KSSV
KSSV 2018년 11월 13일
YOu need to remove the input at the variable _Involvement_Prompt_

댓글을 달려면 로그인하십시오.

답변 (1개)

KSSV
KSSV 2018년 11월 13일
Involvement_Grade = [0];
InvolvementOK = false;
while ~InvolvementOK;
Involvement_Prompt = ('How many involvement points do you expect to recieve? %d?\n (Enter a number between 0 and 10, then press enter); ');
Involvement_Response = input(Involvement_Prompt);
if Involvement_Response < 0
uiwait(warndlg('Your input is too low'));
elseif Involvement_Response > 10
uiwait(warndlg('Your input is too high'));
else
Involvement_Grade = Involvement_Response;
InvolvementOK = true
end
end

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by