Best way to export long double data from C into Matlab

What is the best way to import very large matrices of long double data from C (on Linux) into MATLAB? Please answer so that someone new to both C and MATLAB (that's me) can understand. Thanks.

2 commentaires

Jan
Jan le 23 Oct 2012
Are you talking about 80bit values stored in the memory - if so, how are they stored? Or do you mean 80bit values stored in a text or binary file - if so, please explain the format.
I'm pretty new to the low level details of programming. I see I didn't provide near enough information.
The data is calculated one row at a time by an ode solver. I access it one row at a time. I don't have direct access to the data because it is in an object called an N_Vector. So I access it something like this
realtype *udata;
udata = NV_DATA_P(u);
for (n=0; n<my_length; n++)
printf("%5.4Lf\t", udata[n]);
Note that realtype is probably a long double and a one line C code returned that sizeof(long double) is 16 (bytes) and my system is little endian (does that even matter?).
I can't find the definition of NV_DATA in the documentation.
Note also that I want to save the entire precision (not just the four decimals in the printf statement).
Thanks.

Connectez-vous pour commenter.

Réponses (1)

Sachin Ganjare
Sachin Ganjare le 23 Oct 2012

0 votes

If you are importing from .dat file, refer below link:
Else could you please provide format of file wherein this matrices data reside?
Hope it helps!!!

1 commentaire

Jeff
Jeff le 24 Oct 2012
Please see my comment to the main question for more details (I know, I really didn't provide much at all). I have a long running program which generates data (from an ode solver). I want to save all of the data and import it into MATLAB for analysis. I think the link you provide will help. It is probably best for me to write the data to a file, which I can sneaker-net (remember that term everyone?) to the MATLAB machine.

Connectez-vous pour commenter.

Produits

Question posée :

le 23 Oct 2012

Community Treasure Hunt

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

Start Hunting!

Translated by