I want to let users enter any text into my application. I am using the disp() command for this.
I want the users to be able to enter anything. If they enter an integer I want to save it as a string or integer. If they enter anything else I want to give them a warning.
This code doesn't work. Can you help me fix it?
userVar = disp('Enter an integer: ') if (isinteger(userVar)) % e.g. Enter an integer: 3
A = [A userVar]else% e.g. Enter an integer: 3,4
% e.g. Enter an integer: cha1r
warning('Only integers are accepted.')
Best Answer