MATLAB DATABASE TOOLBOX RELEASE NOTES Podręcznik Użytkownika Strona 655

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 684
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 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.
Przeglądanie stron 654
1 2 ... 650 651 652 653 654 655 656 657 658 659 660 ... 683 684

Komentarze do niniejszej Instrukcji

Brak uwag