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

1 次查看(过去 30 天)
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.

采纳的回答

MathWorks Support Team
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))

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

产品


版本

R2008a

Community Treasure Hunt

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

Start Hunting!

Translated by