473,396 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Reading a MatLab file into C++

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?

--
Vänligen Kerstin Viltersten
(The Cool Giraffe)
Feb 15 '07 #1
3 7230
On 15 Feb, 13:40, "The Cool Giraffe" <giraf...@viltersten.comwrote:
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

Feb 15 '07 #2
On Feb 15, 7:40 am, "The Cool Giraffe" <giraf...@viltersten.com>
wrote:
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?

--
Vänligen Kerstin Viltersten
(The Cool Giraffe)

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/usi...lab_add_in.asp
http://www.codeproject.com/samples/MATLAB_MAT.asp

Feb 15 '07 #3
http://www.mathworks.com/access/help...ile_format.pdf

URL wrapped and got messed up.
Feb 15 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Srinath Avadhanula | last post by:
Hello, I wanted to connect to an already existing MATLAB application from python. From the MATHWORKS documentation at: ...
7
by: laclac01 | last post by:
So I am converting some matlab code to C++. I am stuck at one part of the code. The matlab code uses fread() to read in to a vector a file. It's a binary file. The vector is made up of floats,...
4
by: Sven Jerzembeck | last post by:
Hello guys, is there any possibiliy using Phython code in Matlab. I couldnt find any helpful stuff. Its not graphical stuff I am doing just calculations with arrays and strings. Thanks for ...
2
by: Binod Pant | last post by:
Does any one know of a way to call MATLAB from PHP/Perl? I found the Perl module Math:MATLAB , but it seems not to work on Windows, and it's not easy to install and use. This would enable one to...
8
by: Allen | last post by:
Does anyone agree with me? If you have used Matlab, welcome to discuss it.
10
by: Tyler | last post by:
Hello All: After trying to find an open source alternative to Matlab (or IDL), I am currently getting acquainted with Python and, in particular SciPy, NumPy, and Matplotlib. While I await the...
5
blazedaces
by: blazedaces | last post by:
Ok, so you know my problem, java is running out of memory reading with SAX, the event-based xml parser intended more-so than DOM for extremely large files. I'll try to explain what I've been doing...
4
by: itcecsa | last post by:
Hi, I am implementing a small Python project, what I am going to do is to open Matlab and run some M-files, and get some output from Matlab command prompt. I have no idea how to open Matlab...
7
by: simplyme7 | last post by:
hi I have two files, first file format: (It is 4882 raws) userId country operatingSystem Second file format is: (It is 400,000 raws) userId time
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.