Clear Filters
Clear Filters

Best way to export long double data from C into Matlab

2 views (last 30 days)
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 Comments
Jan
Jan on 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.
Jeff
Jeff on 24 Oct 2012
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.

Sign in to comment.

Answers (1)

Sachin Ganjare
Sachin Ganjare on 23 Oct 2012
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 Comment
Jeff
Jeff on 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.

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!