Preventing text input for a variable
2 views (last 30 days)
Samuel Brewton on 16 Feb 2021
I am working on a function where a user with no prior coding experience should be able to input a series of numbers to define my variables. The variables must be between 1 and 30 and must be an integer.
I currently have preventions to stop numbers outside of 1 and 30 (using logic) and another to stop decimals (using round(Var)).
The last prevention I am looking for is stopping the user from inputing words or letters. Ex: Var=q
I appreciate any help.
Fxn(20) %Input must be between 1 and 30; cannot be a word or letter
if x<1 | x>30
disp("Variable must be between 1 and 30")