MATLAB Answers

How can I limit a set of input data, 6 values, to a min and max point and as an integer

6 views (last 30 days)
Andre du Plessis
Andre du Plessis on 17 Feb 2020
Answered: KSSV on 18 Feb 2020
I am writing a piece of code requesting the user to submit 6 integer numbers in the range [1,59]. I want to make it so that if the user submits an value outside the range or a non integer, the code breaks and displays an error message saying invalid numbers chosen.


Andre du Plessis
Andre du Plessis on 18 Feb 2020
prompt = {'1st','2nd','3rd','4th','5th','6th'};
dlgtitle = 'Choose 6 integers between 1-59';
user1 = inputdlg(prompt,dlgtitle,dims)';
user = round(str2double(user1))

Sign in to comment.

Accepted Answer

KSSV on 18 Feb 2020
if min(user)<1 || max(user)>59
error("Check the input")


Sign in to comment.

More Answers (0)

Sign in to answer this question.


Translated by