| Contents | Index |
This example retrieves images from the SampleDB data source using a sample file that parses image data, matlabroot/toolbox/database/vqb/parsebinary.m.
Connect to the SampleDB data source.
conn = database('SampleDB', '', '');
Specify cellarray as the data return format preference.
setdbprefs('DataReturnFormat','cellarray');
Import the EmployeeID and Photo columns of data from the Employees table.
curs = exec(conn, 'select EmployeeID,Photo from Employees') curs = fetch(curs);
curs.Data
ans =
[1] [21626x1 int8]
[2] [21626x1 int8]
[3] [21722x1 int8]
[4] [21626x1 int8]
[5] [21626x1 int8]
[6] [21626x1 int8]
[7] [21626x1 int8]
[8] [21626x1 int8]
[9] [21626x1 int8]Assign the image element you want to the variable photo.
photo = curs.Data{1,2};
Run parsebinary. This program writes the retrieved data to a file, strips ODBC header information from it, and displays photo as a bitmap image in a figure window. Ensure that your current folder is writable so that the output of parsebinary can be written to it.
cd 'I:\MATLABFiles\myfiles parsebinary(photo, 'BMP');
For more information on parsebinary, enter help parsebinary or view its file in the MATLAB Editor/Debugger by entering open parsebinary.
![]() | Exporting Data Using the Bulk Insert Command | Working with Database Metadata | ![]() |

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