'Double' data is loading as 'single' from database when database reports 'double'
이전 댓글 표시
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
"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
2021년 3월 12일
Stephen23
2021년 3월 12일
@Tim Darrah: a bit more context (other code and processing) might help us to understand where/why this occurs.
Tim Darrah
2021년 3월 12일
채택된 답변
추가 답변 (1개)
Tim Darrah
2021년 3월 18일
댓글 수: 5
Rishik Ramena
2021년 3월 18일
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
2021년 3월 19일
Tim Darrah
2021년 3월 19일
Tim Darrah
2021년 3월 22일
Gordon Burns
2023년 7월 1일
Using fetch() instead of select() solves this problem.
카테고리
도움말 센터 및 File Exchange에서 Database Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



