私は今、次のことを試しています:
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 を返します。