Not Enough Input arguments error

조회 수: 12 (최근 30일)
Isobel Leikis
Isobel Leikis 2022년 4월 30일
댓글: Star Strider 2022년 5월 1일
% generate a random value for x
x = randi([1 100]);
% ask questions and ask for input
prompt1= 'x+4';
ans1 = inputdlg(sprintf("when x = %i \nWhat is x+4?",x));
myicon = imread("Jellybean.png");
%creates a while loop in the event of a correct answer
while input == x+4
msgbox('Correct! The frogs kiss your feet and you move on!',myicon);
%creates an if loop in the event of an incorrect answer
if input ~= x+4
msgbox('Incorrect! You are attacked by frogs! Try again to gain their trust.',myicon);
%retries the loop until the correct answer is given
continue
end
end
%i keep getting this error: Error using input Not enough input arguments. But im not sure where theres more than 1 input

채택된 답변

Star Strider
Star Strider 2022년 4월 30일
I suspect the problem is the ‘input’ variable, since input is a function.
The solution is to rename ‘input’ to something else that makes sense in the context of the rest of the code.
Go frogs!
  댓글 수: 8
Isobel Leikis
Isobel Leikis 2022년 5월 1일
thank you so much for your help!
Star Strider
Star Strider 2022년 5월 1일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by