필터 지우기
필터 지우기

Best way to export long double data from C into Matlab

조회 수: 2 (최근 30일)
Jeff
Jeff 2012년 10월 23일
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