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
2009-6-27
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!