Reading a MatLab file into C++

T

The Cool Giraffe

I have a 3D matrix in MatLab and i have saved it binary
(i think) to a file data.mat and now i'd like to retrieve
those values in C++.

Even though i'm a ground breaking genius working with
extremely innovative frontier of science (joke intended)
i can imagine _SOMEBODY_ needed to perform such an
operation before me as well. Hence, i have a feeling
that there's an easy way to do that.

Am i mistaken? If so, please advise on what to think
about when reading such a file. In other case, what
method to use?
 
G

Gavin Deane

I have a 3D matrix in MatLab and i have saved it binary
(i think) to a file data.mat and now i'd like to retrieve
those values in C++.

Even though i'm a ground breaking genius working with
extremely innovative frontier of science (joke intended)
i can imagine _SOMEBODY_ needed to perform such an
operation before me as well. Hence, i have a feeling
that there's an easy way to do that.

Am i mistaken? If so, please advise on what to think
about when reading such a file. In other case, what
method to use?

You need to ask a MATLAB support forum. This isn't a C++ language
question. You might want to start from
http://www.mathworks.com/matlabcentral/

I believe .mat files are binary (I just looked in one and it didn't
look like text to me). That means that to read one, you need to know
the format of the data. The first question to ask is whether the
format is publically available. If so, it is quite likely that someone
has already written a C++ library for what you need. A MATLAB forum or
Google are where I would start looking.

If you do end up writing something in C++ yourself, one general piece
of advice is to make sure you open your file reading stream in binary
mode. If you end up with specific C++ problems, ask away here.

Gavin Deane
 
R

raddog58c

I have a 3D matrix in MatLab and i have saved it binary
(i think) to a file data.mat and now i'd like to retrieve
those values in C++.

Even though i'm a ground breaking genius working with
extremely innovative frontier of science (joke intended)
i can imagine _SOMEBODY_ needed to perform such an
operation before me as well. Hence, i have a feeling
that there's an easy way to do that.

Am i mistaken? If so, please advise on what to think
about when reading such a file. In other case, what
method to use?


Check out: http://www.mathworks.com/access/helpdesk/help/pdf_doc/
matlab/matfile_format.pdf

Also:
http://www.codeproject.com/samples/matlabeng.asp
http://www.codeproject.com/samples/matlab_c_api.asp
http://www.codeproject.com/macro/using_matlab_add_in.asp
http://www.codeproject.com/samples/MATLAB_MAT.asp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,268
Latest member
AshliMacin

Latest Threads

Top