Borrar filtros
Borrar filtros

Retrieve Double precision Values from a database

1 visualización (últimos 30 días)
Devinya Herath
Devinya Herath el 22 de Ag. de 2011
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 comentario
Devinya Herath
Devinya Herath el 22 de Ag. de 2011
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

Iniciar sesión para comentar.

Respuesta aceptada

Daniel Shub
Daniel Shub el 22 de Ag. de 2011
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)).

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by