Retrieve Double precision Values from a database

2 ビュー (過去 30 日間)
Devinya Herath
Devinya Herath 2011 年 8 月 22 日
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 Center および File ExchangeDatabase Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by