MATLAB: What is the fastest way to determine whether a string is a number

strings

Hi, I have a string x and in order to determine wether it is a number one can do the following
try
flag = isnumeric(eval(x));
catch
flag=false;
end
Is there a better and faster way to do this?
Thanks
Pat.

Best Answer

Probably:
isnan(str2double(str))
This won't need try/catch either.
Anything with eval in it will definitely not be fast.