Reputation: 409
In Matlab, I'm pulling in data from a mySQL database using a statement similar to:
SELECT PrimaryKeyVar, Var1, MyDate, Var2, Var3 FROM MyDatabase.MyTable ORDER BY PrimaryKeyVar DESC LIMIT 4
Among the 4 values returned are some NULLs. Unfortunately, these are imported into Matlab as 'null'
rather than NaN
(in other words, Matlab treats the mySQL NULLs
as strings). Is there a way to import the NULLs
as NaNs
?
I was thinking of including a statement like ...IF(MyDate IS NULL, "????", MyDate) AS MyDate...
(where the "????"
would hold some kind of identifier for the NULLs
) but I'm not sure if that can work.
Upvotes: 1
Views: 106
Reputation: 24127
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.
Upvotes: 1