MATLAB M-file script to test the "getinput" function
Dr. Kris Stewart (stewart@cs.sdsu.edu)
San Diego State Univeristy
% testit.m
%
% getinput has 4 input parameters:
% 1) string to prompt user with (' enter a value between 2 and 4')
% 2) maximum number of attempts for the user to enter a value (5)
% 3) the smallest value that is valid (2)
% 4) the largest value that is valid (4)
%
% getinput has 2 output parameters:
% 1) val (the value that was obtained from the user)
% 2) okay (a logical flag set true if a valid input obtained in maxtries
% attempts; else false)
%
maxtries = 5; minval = 2; maxvalue = 4;
[val,okay] = getinput(' enter a value between 2 and 4',maxtries,minval,maxvalue)
if okay
disp([' val = ' num2str(val)])
else
disp('sorry you did not enter a valid number')
end