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 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