MATLAB: How to store function [x] = input(‘blah’)

gamehelper functionhigh lowinputstoragevariable

Hello, I'm trying to store my input into another variable while being called from another function.
function hiloTest()
gameOver = 0;
while gameOver == 0
[gameOver, guess] = showResults()
end
end
function [gameOver, guess] = showResults()
gameOver = false;
ii = 46;
%I want to store this [x] = inPut() function's input into variable named 'guess'
[x] = inPut()
while (gameOver == 0)
if (guess < ii)
disp('Close, but you need to go a bit higher.');
[x] = inPut();
elseif (guess > ii)
disp('Your guess is high. Please try again.');
[x] = inPut();
else
disp('Right, you got it. Thank you for playing.');
gameOver = true;
end
end
end
function [x] = inPut()
[x] = input('Please enter a number between 1 and 100: ');
end
I still got lots to learn, please help. Thank you in advance 😀

Best Answer

As far as I understand you want that the input variable to be a number called guess. For your usage of the input function that should be simply
guess = x;
But why don't you simplify it into
guess = input('Please enter a number between 1 and 100: ');
The function inPut seems superfluous.