Database Toolbox Previous page   Next Page

BOOLEAN (MATLAB logical) Data

When you import data of the BOOLEAN type, MATLAB reads the data as a logical data type within the cell array or structure, having a value of 0 (false) or 1 (true). Similarly, you can export logical data from MATLAB to a database. This example illustrates both importing and exporting BOOLEAN data. For more information about the MATLAB logical data type, see Logical Types in the MATLAB Programming documentation.

Importing BOOLEAN Data

  1. Set Preferences; for this example, set Data return format to cellarray.
  2. For the Data operation, choose Select.
  3. From Data source, select a data source; for this example, SampleDB.
  4. From Tables, select a table; for this example, Products.
  5. From Fields, select the fields; for this example, ProductName and Discontinued.
  6. Assign the MATLAB workspace variable; for this example, use D.
  7. Click Execute to run the query.
  1. The VQB retrieves a 77x2 array.

  1. Type D in the Command Window and MATLAB displays 77 records, with the first five shown here.
  2. Compare this to the table in Microsoft Access.

  3. In the VQB Data area, double-click D to view the contents in the Array Editor.

  4. In the Array Editor, the logical value for the first product, Chai, appears as false instead of 0 for the cell array. This is to distinguish it as a logical value instead of a numeric 0. In the Array Editor, double-click false. Its logical value, 0, appears in a separate window.


Previous page  Exporting Data Using the VQB Exporting BOOLEAN Data Next page

© 1994-2005 The MathWorks, Inc.