Is there a dataset both matlab and VC++ can use?

Hello, want to program to store a result to file, which dataset can both Matlab and C++ read?
I know Matlab can save it to .mat file but C++ may not be able to read it.
Thanks.

 Accepted Answer

If you want a true database, there is the Database Toolkit.
But if you are talking about .mat files, then
  1. Yes, you can program C++ to read .mat files; but
  2. it is usually easier to transfer the data in binary such as by using fwrite()

7 Comments

Yes, of course I can program C++ to read mat files but I prefer easier ways. Will look at database toolkit. thanks.
Note that there is an official interface and libraries for reading .mat files
Will check that for C++, thanks.
If I transfer the data to binary using fwrite, how to read it in C++?
C++ has fread() that takes similar arguments that you can work with.
The main trick you need to watch out for is that MATLAB uses "column major order" but C++ uses "row major order". That is, in MATLAB, the elements that are adjacent in memory are the ones that are in the same column, whereas in C++ the elements that are adjacent in memory are the ones that are in the same row.
OK, thanks. Will be careful on it. I do not think it affect me too much. :)
So if you address A(I,J) in MATLAB, it would be A[J][I] in C
Thanks, Walter!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!