User`s guide

setdbprefs
7-225
conn = database('MySQL','username','pwd');
Alternatively, you can use the native ODBC interface for an ODBC connection. For
details, see the database function.
Import data into the MATLAB workspace.
curs = exec(conn,...
'select productnumber,productdescription from producttable');
curs = fetch(curs,3);
curs.Data
ans =
[9] 'Victorian Doll'
[8] 'Train Set'
[7] 'Engine Kit'
Resulting data displays as a cell array.
Change the data return format from cellarray to numeric.
setdbprefs('DataReturnFormat','numeric')
Import data into the MATLAB workspace.
curs = exec(conn,...
'select productnumber,productdescription from producttable');
curs = fetch(curs,3);
curs.Data
ans =
9 NaN
8 NaN
7 NaN
In the database, the values for productDescription are character strings, as seen in
the previous example when DataReturnFormat was set to cellarray. Therefore, the
productDescription values cannot be read when they are imported into the MATLAB
workspace using the numeric format. Therefore, MATLAB treats them as NULL numbers
and assigns them the current value for the NullNumberRead property of NaN.
Change the data return format to structure.