Database Toolbox |
Specifying Preferences for NULLS, Data Format, and Error Handling
Using preferences, you can specify
Preference |
Description |
New Value |
---|---|---|
Read NULL numbers as |
How NULL numbers in a database are represented when imported into MATLAB.For the new value, 0 , the NULL data in the example results will appear as 0 's. Previously, they appeared as NaN values. |
0 |
Data return format |
Format for data imported into MATLAB. Select a value based on the type of data you are importing, memory considerations, and your preferred method of working with retrieved data. Cell arrays and structures support mixed data types, but require more memory and are processed more slowly than numeric matrices. Use the cellarray to numeric to reduce memory required. |
numeric |
Error handling |
Behavior for handling errors when importing data. In the Visual Query Builder, setting the value to store or empty means any errors are reported in a dialog box rather than in the Command Window.Set the value to report , which means that any errors from running the query will display immediately in the Command Window. |
report |
setdbprefs
, which is the equivalent function for setting preferences.
A
is 320 bytes, compared to 2720 bytes when we ran the query using the previous settings for preferences. This is because we changed the Data return format to numeric
, where previously it was set to cellarray
. The numeric
format requires far less memory than the cellarray
format. However, the cellarray
(or structure
) format is required if you want to retrieve data that is not all numeric, such as strings. If you use the numeric
format to retrieve data that contains strings, the strings are returned as NULL
values, represented by the preference you specified for Read NULL numbers as.
Saving Preferences
Preferences apply to the current MATLAB session. They are not saved with a query. The default preferences apply when you start a new session, or after clearing all variables (for example, clear all
). It is a good practice to verify the preference settings before you run a query.
Another way to set preferences is by using the setdbprefs
function. To use the same preferences whenever you run MATLAB, include the setdbprefs
function in your startup
file.
Clearing Variables in the Data Area | Viewing Query Results |
© 1994-2005 The MathWorks, Inc.