| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Database Toolbox |
| Contents | Index |
| Learn more about Database Toolbox |
| On this page… |
|---|
Importing BOOLEAN Data from Databases to the MATLAB Workspace Exporting BOOLEAN Data from the MATLAB Workspace to Databases |
BOOLEAN data is imported from databases into the MATLAB workspace as data type logical. This data has a value of 0 (false) or 1 (true), and is stored in a cell array or structure.
This example imports data from the Products table in the Nwind database into the MATLAB workspace.
Assign the query results to the MATLAB workspace variable D.
Click Execute to run the query.
VQB retrieves a 77-by-2 array.
Enter D in the MATLAB Command Window. 77 records are returned; only the first five records appear here due to space constraints.
D =
'Chai' [0]
'Chang' [0]
'Aniseed Syrup' [0]
[1x28 char] [0]
[1x22 char] [1]
Compare these results to the data in Microsoft Access.


In the VQB Data area, double-click D to view its contents in the Variable Editor. The logical value for the first product, Chai, appears as false instead of 0.

In the Variable Editor, double-click false. Its logical value, 0, appears in a separate window.

For more information about MATLAB logical data types, see Logical Types in the MATLAB Programming Fundamentals documentation.
Logical data is exported from the MATLAB workspace to a database as type BOOLEAN. This example adds two rows of data to the Products table in the Nwind database.
In the MATLAB workspace, create P, the structure you want to export.
P.ProductName{1,1}='Chocolate Truffles';
P.Discontinued{1,1}=logical(0);
P.ProductName{2,1}='Guatemalan Coffee';
P.Discontinued{2,1}=logical(1);
Click Execute to run the query.
VQB inserts two new rows into the Products table.
View the table in Microsoft Access to verify that the data was correctly inserted.

![]() | Retrieving BINARY and OTHER Sun Java Data Types | Saving Queries in M-Files | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |