By default, input interprets the user input as a matlab expression and evaluates it. If the user input is not a valid matlab expression then it returns an error. If you want the user to be able to enter something that is not a matlab expression, then you need to pass the 's' option to input:
kbinput = input(' ', 's');
All input (including numbers) is then interpreted as text. If on the next line you meant to test that kbinput is char (instead of the undefined variable next), then the test will always return true. If you want to make sure that the input is truly a number:
kbinput = input(' ', 's');
numericvalue = str2double(kbinput);
if isnan(numericvalue)
error('you did not enter a number');
end
Best Answer