Best way to export long double data from C into Matlab

1 次查看(过去 30 天)
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 个评论
Jan
Jan 2012-10-23
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 2012-10-24
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.

请先登录,再进行评论。

回答(1 个)

Sachin Ganjare
Sachin Ganjare 2012-10-23
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 个评论
Jeff
Jeff 2012-10-24
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by