MATLAB: How to exclude letters as an input

built-in functions

Hello,
I'm working on a project and I'm trying to figure out something and was wondering if someone could help me. I'm asking the user to input positive and non-decimal numbers only. So no strings, no decimals, no negative numbers, no letters, and no blanks.This is my code:
while ( ischar(r) || ischar(c) || isempty(r) || isempty(c))
disp(' ')
disp('You have left an answer blank, or entered a non-numeric value. Please, try again.')
r = input('enter the next row you wish to explore sire: ');
c = input('enter the next column you wish to explore sire: ');
When I run it and input in a letter such as a or b…, my code breaks and an error occurs (the error is Undefined function or variable 'a'.). I tried isletter , but still get the same thing. I would appreciate the help!

Best Answer

r = input('enter the next row you wish to explore sire: ', 's');
c = input('enter the next column you wish to explore sire: ', 's');
while ~isrow(r) || ~isrow(c) || any(r < '0' | r > '9') || any(c < '0' | c > '9')
now whine
and prompt again
end
r = str2double(r);
c = str2double(c);