MATLAB: How to check that input is numerical

I'm trying to create a program that will prompt the user for a numerical input, for example: 'What age are you?'. I know how to prompt the user to ask for an input, but I want to know how to check the answer to make sure it is a numerical figure, ie to stop the user putting in the answer 'twelve'. Any help would be greatly appreciated.
Seán

Best Answer

str2num( inputVal )
will return the number if it is valid or empty otherwise so a
if ~isempty( str2num( inputVal ) )
test would check it is a number, or remove the ~ if you want to check for not a number and give an error message in that case.