0
我想现在以下几点:检测数字在八度
function isNum = isItANum(string)
isNum = isempty(str2num(string))
end
的问题是,如果我有个约会“1998/34/2”,我想我的功能说不。
我想现在以下几点:检测数字在八度
function isNum = isItANum(string)
isNum = isempty(str2num(string))
end
的问题是,如果我有个约会“1998/34/2”,我想我的功能说不。
从help str2num
:
*Caution:* As `str2num' uses the `eval' function to do the
conversion, `str2num' will execute any code contained in the
string S. Use `str2double' instead if you want to avoid the use
of `eval'.
See also: str2double, eval
貌似可以用~isnan(str2double(string))
取代你的功能
做一个循环,让您在拆分单个字符字符串,如果任何字符失败,则返回0