MATLAB DATABASE TOOLBOX RELEASE NOTES Guida Utente Pagina 655

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 684
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 654
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.
Vedere la pagina 654
1 2 ... 650 651 652 653 654 655 656 657 658 659 660 ... 683 684

Commenti su questo manuale

Nessun commento