1

在 Matlab 中,我使用类似于以下语句的语句从 mySQL 数据库中提取数据:

SELECT PrimaryKeyVar, Var1, MyDate, Var2, Var3 FROM MyDatabase.MyTable ORDER BY PrimaryKeyVar DESC LIMIT 4

返回的 4 个值中有一些 NULL。不幸的是,这些被导入到 Matlab 中'null'而不是NaN(换句话说,Matlab 将 mySQLNULLs视为字符串)。有没有办法导入NULLsas NaNs

我正在考虑包括一个声明,例如...IF(MyDate IS NULL, "????", MyDate) AS MyDate...(其中"????"将保存某种标识符NULLs),但我不确定这是否可行。

4

1 回答 1

1

You can control the behaviour of Database Toolbox on null data via preferences. Open the MATLAB Preferences dialog via File->Preferences, and navigate in the left panel to the section for Database Toolbox. Specify the behaviour you'd like in the section Null Data Handling.

Alternatively, you can control the same preferences programatically with the command setdbprefs. You may need to set the values of the preferences NullNumberRead, NullNumberWrite, NullStringRead and NullStringWrite. Type doc setdbprefs for more information.

于 2013-09-20T22:14:27.353 回答