Path: news.mathworks.com!not-for-mail
From: "Dhiman Saha" <saha.dhiman@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Opening mat file in C
Date: Thu, 30 Jul 2009 12:04:01 +0000 (UTC)
Organization: Indian Institute of Technology, Kharagpur
Lines: 46
Message-ID: <h4s27h$3cm$1@fred.mathworks.com>
References: <h4qaei$10m$1@fred.mathworks.com> <h4qhv1$t3$1@fred.mathworks.com> <h4qrph$6o5$1@fred.mathworks.com> <h4riko$h57$1@fred.mathworks.com>
Reply-To: "Dhiman Saha" <saha.dhiman@gmail.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1248955441 3478 172.30.248.37 (30 Jul 2009 12:04:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 30 Jul 2009 12:04:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1919793
Xref: news.mathworks.com comp.soft-sys.matlab:559587


"James Tursa" <aclassyguywithaknotac@hotmail.com> wrote in message <h4riko$h57$1@fred.mathworks.com>...
> "Dhiman Saha" <saha.dhiman@gmail.com> wrote in message <h4qrph$6o5$1@fred.mathworks.com>...
> > "James Tursa" <aclassyguywithaknotac@hotmail.com> wrote in message <h4qhv1$t3$1@fred.mathworks.com>...
> > > "Dhiman Saha" <saha.dhiman@gmail.com> wrote in message <h4qaei$10m$1@fred.mathworks.com>...
> > > > I want to open a mat file which has some two dimensional matrices in a C file. I followed the help file on that but when i compile the file i get lots of errors like "undefined reference to matOpen" and such errors for all the matlab functions. I have included the mat.h file in the include directory of the compiler. I am using the minGW compiler on windows XP. 
> > > > 
> > > > IS there anything I need to include?
> > > > 
> > > > Thanks
> > > > Dhiman
> > > 
> > > Have you also included mex.h or engine.h? Can you show the source code you are trying?
> > > 
> > > James Tursa
> > 
> > I just tried to compile the matdgns.c file given in matlab 
> > edit([matlabroot '/extern/examples/eng_mat/matdgns.c']);
> > This file does not have any mex.h or engine.h included.
> > 
> 
> I just tried it and it compiled and ran fine. Here is what I did:
> 
> - Copied the file matdgns.c from the [matlabroot '/extern/examples/eng_mat'] directory to a work directory.
> 
> - Made that work directory the current directory
> 
> - Issued the following mex -setup command:
> 
> mex -setup
> (then selected the MS VC 8.0 compiler)
> 
> - Issued the following commands (for MS VC 8.0):
> 
> options = [matlabroot '\bin\win32\mexopts\msvc80engmatopts.bat'];
> mex('-f', options, 'matdgns.c', '-v');
> 
> - Ran the program with the following command:
> 
> !matdgns matlab.mat
> 
> James Tursa


Thank you for the reply. But can i use matdgns.c file on the MinGW compiler. Also how can i open the mat file using C in a system that does not have matlab installed. (If its required I can also post this as a new problem.)

Dhiman Saha