Wrong Values of Doubles from .mat file in C
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have a C program reading a .mat file. The file contains 2 1d arrays of doubles. The program gets a pointer to the beginning of an array of doubles by using mxGetDoubles(). It can successfully read all the values, however there appears to be a scaling problem when printing them with printf("%lf\n", ...) , e.g.
13.69798 displays as as 24.553575
48.94982 displays as as 57.016571
Matlab is R2022a
GCC is x86_64 V11.3.0 (MINGW running in Windows)
Could there be a difference in encoding? I thought they would both use IEEE 754 double encoding.
2 Commenti
Walter Roberson
il 28 Mar 2023
?? mxGetDoubles() is not (in itself) suitable for reading doubles from a .mat file.
Have you tested with https://www.mathworks.com/help/matlab/matlab_external/reading-a-mat-file-in-cc.html ?
Risposte (1)
Vedere anche
Categorie
Scopri di più su Write C Functions Callable from MATLAB (MEX Files) in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!