Retrieve Double precision Values from a database

1 次查看(过去 30 天)
I have a database table that contains a two columns (X and Y) of double precision data. I wanted to retrieve these data to Matlab. I used the following code for doing this (Note that the ‘conn’ is the connection name.
curs = exec(conn, 'select x, y from Mytable');
setdbprefs('DataReturnFormat','cellarray');
curs = fetch(curs, 10);
AA = curs.Data;
Then I wanted to see all the X values and used the following code.
x=[AA{:,1}]'
The result is given below.
x =
1.0e+006 *
-2.6859
-2.6859
-2.6859
-2.6859
-2.6859
-2.6859
-2.6859
-2.6859
-2.6859
-2.6859
Please note that the result given by Matlab contains the TRUNCATED values of X.
Given below is the list of exact values for X in the database table.
-2685857.83152909 -2685873.29058222 -2685892.47755554 -2685878.77198631 -2685853.37410012 -2685864.72544327 -2685876.71371916 -2685886.58031066 -2685875.18191007 -2685856.28515618
I want to get these exact values to Matlab instead of the truncated values. Please help.
  1 个评论
Devinya Herath
Devinya Herath 2011-8-22
Given below is the exact values of X in the database table.
-2685857.83152909
-2685873.29058222
-2685892.47755554
-2685878.77198631
-2685853.37410012
-2685864.72544327
-2685876.71371916
-2685886.58031066
-2685875.18191007
-2685856.28515618

请先登录,再进行评论。

采纳的回答

Daniel Shub
Daniel Shub 2011-8-22
MATLAB is most likely fetching the complete data, but providing you a truncated view.
doc format
you could also check do
x(1) == -2685857.83152909
x(1) -(-2685857.83152909)
ideally the first would return 0, but there might be some small machine precision differences. Ideally, x(1) -(-2685857.83152909) should be the same magnitude as eps(x(1)).

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Database Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by