'Double' data is loading as 'single' from database when database reports 'double'
Afficher commentaires plus anciens
I cant figure out what the deal is with this, the picture says it all. I'm using postgres, ODBC, windows 10. In the advanced options I have the default for "Numeric" as 'double'. In my database, the column types are 'double precision' (not float), but MATLAB keeps loading them as single.
?

4 commentaires
"MATLAB even recognizes that the datatype is double."
MATLAB presumes everything numeric is double unless told differently; you can't infer that the options object is anything but default settings.
If the data are actually returned as single, that would imply that that's what the ODBC connection did to it.
Are the data being interpreted as numerically correct? If so, what's the real problem; you can always cast to double() if you really, really want to.
Tim Darrah
le 12 Mar 2021
Stephen23
le 12 Mar 2021
@Tim Darrah: a bit more context (other code and processing) might help us to understand where/why this occurs.
Tim Darrah
le 12 Mar 2021
Réponse acceptée
Plus de réponses (1)
Tim Darrah
le 18 Mar 2021
5 commentaires
Rishik Ramena
le 18 Mar 2021
opts = databaseImportOptions(conn, 'eqc_battery_tb');
data = sqlread(conn,tablename,opts);
Try using sqlread to force the import options on the selected table.
Tim Darrah
le 19 Mar 2021
Tim Darrah
le 19 Mar 2021
Tim Darrah
le 22 Mar 2021
Gordon Burns
le 1 Juil 2023
Using fetch() instead of select() solves this problem.
Catégories
En savoir plus sur Database Toolbox dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



