Thread Subject: How does the MATLAB Compiler deal with .mat files?

Subject: How does the MATLAB Compiler deal with .mat files?

From: William

Date: 26 Jun, 2009 21:49:01

Message: 1 of 8

I am trying to create an executable file using the MATLAB compiler. I am creating a GUI that uses a .mat file for loading data every time it is opened, but the .mat file is not being integrated into the executable files. Without it, my GUI throws an error.

The command for compiling MATLAB files into an executable is:

mcc -m stuff.m moreStuff.m evenMoreStuff.m

I have tried to add the .mat file to the list (after -m), but it doesn't seem to work properly. how does the MATLAB compiler deal with .mat files and have can I add them for the .exe to use?

Thank you,
Billy

Subject: How does the MATLAB Compiler deal with .mat files?

From: Bruno Luong

Date: 26 Jun, 2009 23:02:03

Message: 2 of 8

"William" <w_king10@yahoo.com> wrote in message <h23fod$8p2$1@fred.mathworks.com>...
> I am trying to create an executable file using the MATLAB compiler. I am creating a GUI that uses a .mat file for loading data every time it is opened, but the .mat file is not being integrated into the executable files. Without it, my GUI throws an error.
>
> The command for compiling MATLAB files into an executable is:
>
> mcc -m stuff.m moreStuff.m evenMoreStuff.m
>
> I have tried to add the .mat file to the list (after -m), but it doesn't seem to work properly. how does the MATLAB compiler deal with .mat files and have can I add them for the .exe to use?

Why you should add them in the EXE file? Any data files should keep separately. They will be used as normal.

Bruno

Subject: How does the MATLAB Compiler deal with .mat files?

From: William

Date: 28 Jul, 2009 02:09:02

Message: 3 of 8

I guess I don't really understand how to leave it seperately. The MAT file is used by the program everytime the application is launched. It contains parameters that the program needs. I am looking to create an executable with everything required, so I can send the whole thing to people who will use the program. Keeping the MAT files separate, will just be confusing for the end user.

How can I integrate needed MAT files in with an exe when it is created using the Matlab compiler. Has anyone been able to do this yet?

Subject: How does the MATLAB Compiler deal with .mat files?

From: Bruno Luong

Date: 28 Jul, 2009 05:57:01

Message: 4 of 8

"William" <w_king10@yahoo.com> wrote in message <h4lmjt$4mh$1@fred.mathworks.com>...
> I guess I don't really understand how to leave it seperately. The MAT file is used by the program everytime the application is launched. It contains parameters that the program needs. I am looking to create an executable with everything required, so I can send the whole thing to people who will use the program. Keeping the MAT files separate, will just be confusing for the end user.
>
> How can I integrate needed MAT files in with an exe when it is created using the Matlab compiler. Has anyone been able to do this yet?

Pack your files with an application installer (such as NSIS http://nsis.sourceforge.net/Main_Page). This is not the job of the compiler.

Bruno

Subject: How does the MATLAB Compiler deal with .mat files?

From: William

Date: 29 Jul, 2009 00:22:02

Message: 5 of 8

OK...that makes no sense to me either. I will have to tell the installer where to put the .mat file. Correct? Therefore, when I use the mcc command to create the executable, I should then be able to put the required .mat file somewhere manually without using the installer. Correct? Where do I put it? In which folder?

I have not found the appropriate location and cannot find documentation in MATLAB for dealing with .mat files in executables. NSIS, as far as I know, isn't designed to work specifically with MATLAB files. Therefore, it won't know what to do with the file I am having trouble with.

I appreciate your help, but pointing me in the direction of random programs without specific instructions on where to put things is not helping me solve my original problem...getting my compiled application to work. The .mat file in my program is a file that is used every time my program launches and every time it closes. It holds the configuration values that are saved upon closing and loaded upon launching. My application looks for that file in a specific place. However, no matter where I put it, the application doesn't recognize it once compiled. Is there something I'm missing?

Thanks,
Billy

Subject: How does the MATLAB Compiler deal with .mat files?

From: TideMan

Date: 29 Jul, 2009 02:10:03

Message: 6 of 8

On Jul 29, 12:22 pm, "William" <w_kin...@yahoo.com> wrote:
> OK...that makes no sense to me either.  I will have to tell the installer where to put the .mat file.  Correct?  Therefore, when I use the mcc command to create the executable, I should then be able to put the required .mat file somewhere manually without using the installer.  Correct?  Where do I put it?  In which folder?  
>
> I have not found the appropriate location and cannot find documentation in MATLAB for dealing with .mat files in executables.  NSIS, as far as I know, isn't designed to work specifically with MATLAB files.  Therefore, it won't know what to do with the file I am having trouble with.  
>
> I appreciate your help, but pointing me in the direction of random programs without specific instructions on where to put things is not helping me solve my original problem...getting my compiled application to work.  The .mat file in my program is a file that is used every time my program launches and every time it closes.  It holds the configuration values that are saved upon closing and loaded upon launching.  My application looks for that file in a specific place.  However, no matter where I put it, the application doesn't recognize it once compiled.  Is there something I'm missing?
>
> Thanks,
> Billy

Yes, you are missing something: the sense to listen to the good advice
that Bruno has given you.

When you run your program on your own machine, where does the .mat
file sit?
Then that is exactly where it should sit when you run it on your
users' machines, be that the current directory or somewhere else.
I would write a ReadMe to explain how the program must be installed,
then zip it up along with the .exe and .mat files using WinRAR or
similar. Most users can handle that.

Subject: How does the MATLAB Compiler deal with .mat files?

From: ImageAnalyst

Date: 29 Jul, 2009 02:50:01

Message: 7 of 8

On Jul 28, 8:22 pm, "William" <w_kin...@yahoo.com> wrote:
> OK...that makes no sense to me either.  I will have to tell the installer where to put the .mat file.  Correct?  Therefore, when I use the mcc command to create the executable, I should then be able to put the required .mat file somewhere manually without using the installer.  Correct?  Where do I put it?  In which folder?  
>
> I have not found the appropriate location and ...
[snip].  

> Thanks,
> Billy

Billy:
You should probably put the mat file in the same folder as your
executable. The trick is that unless you put a "cd somepath" in your
startup.m file when you compile it, it will most likely startup with
"my documents\MATLAB" as the current folder when you run your
executable and if you don't put the full path of your mat file, then
it will look there, which is most likely NOT where you installed your
executable in. I suggest you play around with this code (the ShowPath
() function). Also, look at the url (in the comment section) for a
discussion Bruno and others had to help explain it to you (it was
basically the same question you're having)

% Returns the path of the executable.
% http://groups.google.com/group/comp.soft-sys.matlab/browse_frm/thread/b326963a69020d8b/55ac59a943d
% ac841?hl=en&lnk=gst&q=current+directory+exe#55ac59a943dac841
% My test program gives the following output:
% pwd: C:\WINDOWS
% AppRootPath: C:\DOCUME~1\username\LOCALS~1\Temp\username
\mcrCache7.10\
% userpath: C:\Documents and Settings\username\My Documents\MATLAB;
% showpath: D:\Projects\testPath
%
%
% The test program was
% function testPath()
% % mcc -mv testPath
% disp(['pwd: ' pwd]);
% disp(['AppRootPath: ' AppRootPath()])
% disp(['userpath: ' userpath])
% disp(['showpath: ' showpath()]);
% input('Press return');
% end
function [thePath] = ShowPath()
% Show EXE path:
if isdeployed % Stand-alone mode.
[status, result] = system('set PATH');
thePath = char(regexpi(result, 'Path=(.*?);', 'tokens', 'once'));
else % Running from MATLAB.
[macroFolder, baseFileName, ext] = fileparts(mfilename('fullpath'));
thePath = macroFolder;
% thePath = pwd;
end
return ;

William:
Use the above code to construct the full path of your mat file, which
(like I said) I'd recommend putting in the same folder as your
executable. It works for me. But after that, you'll still have to
distribute your mat file with your executable and any other run-time
files that are needed that can't be built into the executable, such as
documentation, help files, sample data files, splash images, etc. I
use the Wise installer to bundle all these up into a single
installation file, but you can use whatever installation package you
want.
Good luck,
ImageAnalyst

Subject: How does the MATLAB Compiler deal with .mat files?

From: William

Date: 3 Aug, 2009 23:57:03

Message: 8 of 8

Thanks for the reply. I will try this tonight when I get to the lab. I understand what you are saying and appreciate what Bruno was trying to tell me. I just get frustrated when I get one word answers with no real explanation. Hopefully, setting the path will fix my problem.

Billy

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
nsis Sprinceana 28 Jul, 2009 03:00:42
exe William 27 Jul, 2009 22:14:06
mcc William 27 Jul, 2009 22:14:06
c William 26 Jun, 2009 17:54:02
compiler William 26 Jun, 2009 17:54:02
m William 26 Jun, 2009 17:54:02
superman William 26 Jun, 2009 17:54:02
mat William 26 Jun, 2009 17:54:02
gui William 26 Jun, 2009 17:54:01
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com