Is it possible to directly retrieve data in a matrix using the FETCH function in Database Toolbox (R2008a)?

1 view (last 30 days)
I would like to know if data can be retrieved from a database directly in a numeric matrix format instead of having to convert the cell returned by FETCH into a matrix using a function such as CELL2MAT.
Such a feature is afforded by the XLSREAD function.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
The Database Toolbox FETCH function returns all of the query data in a single cell array and does not afford the ability to directly retrieve numeric data. Any conversion from cell to matrix would have to be done in the MATLAB environment. This is also true for the XLSREAD function in that the data retrieval routine returns a cell array which is then parsed in a helper function "parse_data" on line 350 of XLSREAD. You can view this code by executing the following at the MATLAB prompt and use it as a basis to write a similar parsing routine for your application:
edit xlsread
In addition to the CELL2MAT function, you may also find the concatenation operation (square brackets) and the CHAR function useful in converting cell data to matrix data. For example,
x = {3, 'String1'; 4, 'String2'};
xmat1 = [x{:,1}]
xmat2 = vertcat(x{:,1})
xchar = char(x(:,2))

More Answers (0)

Categories

Find more on Data Type Conversion in Help Center and File Exchange

Products


Release

R2008a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!