<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/257301</link>
    <title>MATLAB Central Newsreader - Opening mat file in C</title>
    <description>Feed for thread: Opening mat file in C</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Wed, 29 Jul 2009 20:12:02 -0400</pubDate>
      <title>Opening mat file in C</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/257301#669236</link>
      <author>Dhiman Saha</author>
      <description>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 &quot;undefined reference to matOpen&quot; 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. &lt;br&gt;
&lt;br&gt;
IS there anything I need to include?&lt;br&gt;
&lt;br&gt;
Thanks&lt;br&gt;
Dhiman</description>
    </item>
    <item>
      <pubDate>Wed, 29 Jul 2009 22:20:18 -0400</pubDate>
      <title>Re: Opening mat file in C</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/257301#669271</link>
      <author>James Tursa</author>
      <description>&quot;Dhiman Saha&quot; &amp;lt;saha.dhiman@gmail.com&amp;gt; wrote in message &amp;lt;h4qaei$10m$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; 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 &quot;undefined reference to matOpen&quot; 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. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; IS there anything I need to include?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks&lt;br&gt;
&amp;gt; Dhiman&lt;br&gt;
&lt;br&gt;
Have you also included mex.h or engine.h? Can you show the source code you are trying?&lt;br&gt;
&lt;br&gt;
James Tursa</description>
    </item>
    <item>
      <pubDate>Thu, 30 Jul 2009 01:08:01 -0400</pubDate>
      <title>Re: Opening mat file in C</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/257301#669298</link>
      <author>Dhiman Saha</author>
      <description>&quot;James Tursa&quot; &amp;lt;aclassyguywithaknotac@hotmail.com&amp;gt; wrote in message &amp;lt;h4qhv1$t3$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Dhiman Saha&quot; &amp;lt;saha.dhiman@gmail.com&amp;gt; wrote in message &amp;lt;h4qaei$10m$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; 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 &quot;undefined reference to matOpen&quot; 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. &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; IS there anything I need to include?&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Thanks&lt;br&gt;
&amp;gt; &amp;gt; Dhiman&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Have you also included mex.h or engine.h? Can you show the source code you are trying?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; James Tursa&lt;br&gt;
&lt;br&gt;
I just tried to compile the matdgns.c file given in matlab &lt;br&gt;
edit([matlabroot '/extern/examples/eng_mat/matdgns.c']);&lt;br&gt;
This file does not have any mex.h or engine.h included.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Dhiman</description>
    </item>
    <item>
      <pubDate>Thu, 30 Jul 2009 07:38:00 -0400</pubDate>
      <title>Re: Opening mat file in C</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/257301#669343</link>
      <author>James Tursa</author>
      <description>&quot;Dhiman Saha&quot; &amp;lt;saha.dhiman@gmail.com&amp;gt; wrote in message &amp;lt;h4qrph$6o5$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;James Tursa&quot; &amp;lt;aclassyguywithaknotac@hotmail.com&amp;gt; wrote in message &amp;lt;h4qhv1$t3$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &quot;Dhiman Saha&quot; &amp;lt;saha.dhiman@gmail.com&amp;gt; wrote in message &amp;lt;h4qaei$10m$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; 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 &quot;undefined reference to matOpen&quot; 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. &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; IS there anything I need to include?&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Thanks&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Dhiman&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Have you also included mex.h or engine.h? Can you show the source code you are trying?&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; James Tursa&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I just tried to compile the matdgns.c file given in matlab &lt;br&gt;
&amp;gt; edit([matlabroot '/extern/examples/eng_mat/matdgns.c']);&lt;br&gt;
&amp;gt; This file does not have any mex.h or engine.h included.&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
I just tried it and it compiled and ran fine. Here is what I did:&lt;br&gt;
&lt;br&gt;
- Copied the file matdgns.c from the [matlabroot '/extern/examples/eng_mat'] directory to a work directory.&lt;br&gt;
&lt;br&gt;
- Made that work directory the current directory&lt;br&gt;
&lt;br&gt;
- Issued the following mex -setup command:&lt;br&gt;
&lt;br&gt;
mex -setup&lt;br&gt;
(then selected the MS VC 8.0 compiler)&lt;br&gt;
&lt;br&gt;
- Issued the following commands (for MS VC 8.0):&lt;br&gt;
&lt;br&gt;
options = [matlabroot '\bin\win32\mexopts\msvc80engmatopts.bat'];&lt;br&gt;
mex('-f', options, 'matdgns.c', '-v');&lt;br&gt;
&lt;br&gt;
- Ran the program with the following command:&lt;br&gt;
&lt;br&gt;
!matdgns matlab.mat&lt;br&gt;
&lt;br&gt;
James Tursa</description>
    </item>
    <item>
      <pubDate>Thu, 30 Jul 2009 12:04:01 -0400</pubDate>
      <title>Re: Opening mat file in C</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/257301#669401</link>
      <author>Dhiman Saha</author>
      <description>&quot;James Tursa&quot; &amp;lt;aclassyguywithaknotac@hotmail.com&amp;gt; wrote in message &amp;lt;h4riko$h57$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Dhiman Saha&quot; &amp;lt;saha.dhiman@gmail.com&amp;gt; wrote in message &amp;lt;h4qrph$6o5$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &quot;James Tursa&quot; &amp;lt;aclassyguywithaknotac@hotmail.com&amp;gt; wrote in message &amp;lt;h4qhv1$t3$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &quot;Dhiman Saha&quot; &amp;lt;saha.dhiman@gmail.com&amp;gt; wrote in message &amp;lt;h4qaei$10m$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; 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 &quot;undefined reference to matOpen&quot; 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. &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; IS there anything I need to include?&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; Thanks&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; Dhiman&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Have you also included mex.h or engine.h? Can you show the source code you are trying?&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; James Tursa&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; I just tried to compile the matdgns.c file given in matlab &lt;br&gt;
&amp;gt; &amp;gt; edit([matlabroot '/extern/examples/eng_mat/matdgns.c']);&lt;br&gt;
&amp;gt; &amp;gt; This file does not have any mex.h or engine.h included.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I just tried it and it compiled and ran fine. Here is what I did:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; - Copied the file matdgns.c from the [matlabroot '/extern/examples/eng_mat'] directory to a work directory.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; - Made that work directory the current directory&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; - Issued the following mex -setup command:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; mex -setup&lt;br&gt;
&amp;gt; (then selected the MS VC 8.0 compiler)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; - Issued the following commands (for MS VC 8.0):&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; options = [matlabroot '\bin\win32\mexopts\msvc80engmatopts.bat'];&lt;br&gt;
&amp;gt; mex('-f', options, 'matdgns.c', '-v');&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; - Ran the program with the following command:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; !matdgns matlab.mat&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; James Tursa&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
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.)&lt;br&gt;
&lt;br&gt;
Dhiman Saha</description>
    </item>
    <item>
      <pubDate>Thu, 30 Jul 2009 12:58:09 -0400</pubDate>
      <title>Re: Opening mat file in C</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/257301#669415</link>
      <author>Ashish Uthama</author>
      <description>On Thu, 30 Jul 2009 08:04:01 -0400, Dhiman Saha &amp;lt;saha.dhiman@gmail.com&amp;gt;  &lt;br&gt;
wrote:&lt;br&gt;
&lt;br&gt;
&amp;gt; &quot;James Tursa&quot; &amp;lt;aclassyguywithaknotac@hotmail.com&amp;gt; wrote in message  &lt;br&gt;
&amp;gt; &amp;lt;h4riko$h57$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt;&amp;gt; &quot;Dhiman Saha&quot; &amp;lt;saha.dhiman@gmail.com&amp;gt; wrote in message  &lt;br&gt;
&amp;gt;&amp;gt; &amp;lt;h4qrph$6o5$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt;&amp;gt; &amp;gt; &quot;James Tursa&quot; &amp;lt;aclassyguywithaknotac@hotmail.com&amp;gt; wrote in message  &lt;br&gt;
&amp;gt;&amp;gt; &amp;lt;h4qhv1$t3$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt;&amp;gt; &amp;gt; &amp;gt; &quot;Dhiman Saha&quot; &amp;lt;saha.dhiman@gmail.com&amp;gt; wrote in message  &lt;br&gt;
&amp;gt;&amp;gt; &amp;lt;h4qaei$10m$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt;&amp;gt; &amp;gt; &amp;gt; &amp;gt; I want to open a mat file which has some two dimensional matrices  &lt;br&gt;
&amp;gt;&amp;gt; in a C file. I followed the help file on that but when i compile the  &lt;br&gt;
&amp;gt;&amp;gt; file i get lots of errors like &quot;undefined reference to matOpen&quot; and  &lt;br&gt;
&amp;gt;&amp;gt; such errors for all the matlab functions. I have included the mat.h  &lt;br&gt;
&amp;gt;&amp;gt; file in the include directory of the compiler. I am using the minGW  &lt;br&gt;
&amp;gt;&amp;gt; compiler on windows XP.&lt;br&gt;
&amp;gt;&amp;gt; &amp;gt; &amp;gt; &amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; &amp;gt; &amp;gt; &amp;gt; IS there anything I need to include?&lt;br&gt;
&amp;gt;&amp;gt; &amp;gt; &amp;gt; &amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; &amp;gt; &amp;gt; &amp;gt; Thanks&lt;br&gt;
&amp;gt;&amp;gt; &amp;gt; &amp;gt; &amp;gt; Dhiman&lt;br&gt;
&amp;gt;&amp;gt; &amp;gt; &amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; &amp;gt; &amp;gt; Have you also included mex.h or engine.h? Can you show the source  &lt;br&gt;
&amp;gt;&amp;gt; code you are trying?&lt;br&gt;
&amp;gt;&amp;gt; &amp;gt; &amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; &amp;gt; &amp;gt; James Tursa&lt;br&gt;
&amp;gt;&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; &amp;gt; I just tried to compile the matdgns.c file given in matlab&lt;br&gt;
&amp;gt;&amp;gt; &amp;gt; edit([matlabroot '/extern/examples/eng_mat/matdgns.c']);&lt;br&gt;
&amp;gt;&amp;gt; &amp;gt; This file does not have any mex.h or engine.h included.&lt;br&gt;
&amp;gt;&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; I just tried it and it compiled and ran fine. Here is what I did:&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; - Copied the file matdgns.c from the [matlabroot  &lt;br&gt;
&amp;gt;&amp;gt; '/extern/examples/eng_mat'] directory to a work directory.&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; - Made that work directory the current directory&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; - Issued the following mex -setup command:&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; mex -setup&lt;br&gt;
&amp;gt;&amp;gt; (then selected the MS VC 8.0 compiler)&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; - Issued the following commands (for MS VC 8.0):&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; options = [matlabroot '\bin\win32\mexopts\msvc80engmatopts.bat'];&lt;br&gt;
&amp;gt;&amp;gt; mex('-f', options, 'matdgns.c', '-v');&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; - Ran the program with the following command:&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; !matdgns matlab.mat&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; James Tursa&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Thank you for the reply. But can i use matdgns.c file on the MinGW  &lt;br&gt;
&amp;gt; compiler. Also how can i open the mat file using C in a system that does  &lt;br&gt;
&amp;gt; not have matlab installed. (If its required I can also post this as a  &lt;br&gt;
&amp;gt; new problem.)&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Dhiman Saha&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Dhiman,&lt;br&gt;
&lt;br&gt;
I would first try out what James suggested to ensure that the documented  &lt;br&gt;
workflow runs cleanly. I would then start out customizing it for my  &lt;br&gt;
workflow.&lt;br&gt;
&lt;br&gt;
Did you have a chance to peruse this document?&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&quot;http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_external/f30937.html&quot;&gt;http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_external/f30937.html&lt;/a&gt;&lt;br&gt;
Or please paste this in the MATLAB command window:&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;web([docroot,'/techdoc/matlab_external/f30937.html'])&lt;br&gt;
&lt;br&gt;
Specially this section which talks about compilation and deployment to  &lt;br&gt;
systems without MATLAB.&lt;br&gt;
&lt;br&gt;
Please find more details online at:&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&quot;http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_external/f19027.html&quot;&gt;http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_external/f19027.html&lt;/a&gt;&lt;br&gt;
Or please paste this in the MATLAB command window:&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;web([docroot,'/techdoc/matlab_external/f19027.html'])&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Another trick is to use the -v option with the mex command to figure out  &lt;br&gt;
the actual command line args sent to the compiler. You could use this  &lt;br&gt;
information to then configure your compiler outside MATLAB to pass the  &lt;br&gt;
required settings/libraries/include files.</description>
    </item>
  </channel>
</rss>

