필터 지우기
필터 지우기

Using .mat file with deployed application

조회 수: 11 (최근 30일)
Kamuran
Kamuran 2016년 1월 13일
댓글: Harsheel 2016년 1월 16일
I have a GUI application and I created executable using Matlab compiler. I did not receive any error message during packaging, I added several .mat files during packaging as additional files. User chooses an option and according to that option several of that .mat files are loaded.
I installed the application in a mac computer which does not have MATLAB. So I installed MCR and installed my program but it simply does not run. The program runs w/o a problem before creating the executable. I was wondering, if loading .mat files are not possible with deployed applications.
My question is ..can I use .mat files as I am doing it now?
Thank you
  댓글 수: 3
jgg
jgg 2016년 1월 13일
Adam is correct; you usually need to locate them in the same directory, or provide a relative path.
If the .mat files don't need to be moved around or switched out, it's usually easiest to just -a them into the file when you compile; then, it's as if they're always in the same directory (and you don't need .mat files floating around).
Kamuran
Kamuran 2016년 1월 15일
I realized that the reason for my deployed GUI is not working is something else. It was something about MAC OSX and MCR configuration which I am still trying to solve. http://www.mathworks.com/matlabcentral/answers/263824-mcr-with-mac-and-environment-variable#answer_206212
in other word, you can simply add the .mat file to additional files during packaging. It worked fine with Windows.

댓글을 달려면 로그인하십시오.

답변 (2개)

Harsheel
Harsheel 2016년 1월 15일
You can use the following command:
mcc -m myMainFile.m -a matFile1.mat -a somePath/matFile2.mat
Now, in the "deployed" M file you can access the file directly as:
load('matFile2.mat'); % without the prefix somePath
In case the matFile2.mat is not on MATLAB Path then you can write your code something like:
if ~isdeployed
% matlab mode
load('somePath/matFile2.mat'); % this will ensure that MATLAB finds this file because somePath is not on matlabpath
else
% deployed mode
load('matFile2.mat'); % no need to fully qualify the path, the EXE will be able to find the file
end
Do avoid "locating" files in the deployed environment.
  댓글 수: 1
Kamuran
Kamuran 2016년 1월 15일
I realized that the reason for my deployed GUI is not working is something else. It was something about MAC OSX and MCR configuration which I am still trying to solve. http://www.mathworks.com/matlabcentral/answers/263824-mcr-with-mac-and-environment-variable#answer_206212
in other word, you can simply add the .mat file to additional files during packaging. It worked fine with Windows.

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2016년 1월 15일
I'm really only familiar with Windows, not Mac.
What are the error messages? Did you see any anywhere?
Worst case, put in a bunch of messages
uiwait(helpdlg('Now I am about to run this part of the code...'));
and see how far you get.
  댓글 수: 3
Image Analyst
Image Analyst 2016년 1월 16일
But I thought you already did "simply add the .mat file to additional files during packaging" and you said it didn't work. You said "I added several .mat files during packaging as additional files" and it wasn't working. Now you say that you that you can do that. I'm confused. Did that work or not? Is it working or not? Maybe you should call the tech support on Tuesday (Monday is a holiday in the US).
Harsheel
Harsheel 2016년 1월 16일
I guess on MAC he was getting a different error where the compiled application didn't work at all. That's because unlike Win on MAC you need to set up environment variables like DYLD_LIBRARY_PATH. HTH

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MATLAB Compiler에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by