MATLAB: Can isstrprop search for 2 properties

isstrpropMATLAB

Im attempting to debug erroneous input to retreive a valid input from a user.
I want the input to be only a numeric value and am using isstrprop to test if the input is a digit,
however isstrprop(input, 'digit') returns false if the value has a decimal place. (as a period is not a digit)
Can I use isstrprop to search for digits and decimal places, or is there a better way of acheiving the same result?
Here is my code:
clear, clc;
NumInput = ('');
while isempty(NumInput)
NumInput = input('Hello!\nWelcome to my unit converter!\nPlease enter a numerical value to convert:\n\n', 's');
NumTest = isstrprop(NumInput, 'digit'); %Testing for digits
AlphaTest = isstrprop(NumInput, 'alpha'); %Testing for letters
AlphaNumTest = isstrprop(NumInput, 'AlphaNum'); %Testing for combination
if NumTest(1,:) == 1
NumInput = str2double(NumInput);
disp(NumInput);
elseif AlphaTest(1,:) == 1
fprintf('Please enter only a numeric value.\n\n');
NumInput = ('');
continue
elseif AlphaNumTest(1,:) == 1
NumTest = isstrprop(NumInput, 'digit');
NumsOnly = find(NumTest);
NumInput = str2double(NumInput(NumsOnly));
fprintf('\nOnly numerical values can be entered;\nUsing %1.5g\n\n', NumInput);
else
error('Please enter only a numerical value:');
NumInput = ('');
end
end
Surely these is a better way?

Best Answer

I would really recommend you use the approach of letting matlab do the conversion for you as I wrote in my comment and as Rik answered. It's really the most flexible and doesn't unnecessarily restrict the user from entering valid inputs.
If you're hell bent on only allowing numbers with no 'e' or 'd' notation, the following regular expression should work. It does more than just checking that the text just contain the allowed characters. It actually checks that the expression makes a valid number:
isvalid = ~isempty(regexp(strinput, '^[+-]?(\d*\.)?\d+$'))