Standalone application works in MATLAB but not outside
古いコメントを表示
I have an application that works perfectly in MATLAB but when compiled as a standalone application does not...
With a try and catch statement I think I discovered that the problem is the data file... I have a data file called Data.mat, I think that the standalone application is not able to find it. The function I am using to find the path for Data.mat is the following:
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.
thePath=pwd;
end
The main program call this function in this way:
try
imgFile1 = fullfile(showpath, 'Data');
shipp=load(imgFile1);
catch err
if ~exist(imgFile1, 'file');
errordlg('File does not exist','Input Error');
else
rep = getReport(err, 'extended');
msgbox(rep)
end
end
Where is the mistake?
採用された回答
その他の回答 (7 件)
Robert Cumming
2011 年 4 月 11 日
if your code isn't working that indicates your variable
thePath
is different when deployed and when not. Try printing it to the screen to check what it is. e.g something like:
function test
disp ( ['PWD=', pwd ] );
disp ( ['showPath=', showpath] )
end
function [thePath]=showpath()
% Show EXE path:
[status, result] = system('set PATH');
thePath = char(regexpi(result, 'Path=(.*?);', 'tokens', 'once'));
end
Check function both in Matlab and compiled.
condor
2011 年 4 月 11 日
0 投票
2 件のコメント
Kaustubha Govind
2011 年 4 月 11 日
Have you added Data.mat to the "Other files" section in deploytool?
condor
2011 年 4 月 11 日
Robert Cumming
2011 年 4 月 11 日
0 投票
I've never used the deploytool - I still do everything from command line.
But having a look at it, have you added your Data.mat to the package, then after you build the exe you package it up - which will create a ZIP file or a self extracting exe which should contain your exe and data file...
condor
2011 年 4 月 11 日
condor
2011 年 4 月 11 日
0 投票
2 件のコメント
Robert Cumming
2011 年 4 月 11 日
src is the files generated by the compiler during compilation
distrib - is the files to be distributed.
condor
2011 年 4 月 11 日
condor
2011 年 4 月 11 日
3 件のコメント
Robert Cumming
2011 年 4 月 11 日
did you add it to the build or the package part?
can you see the file in the dir? (I suspect not)
condor
2011 年 4 月 11 日
Robert Cumming
2011 年 4 月 11 日
if you look in explorer do you see the file?
condor
2011 年 4 月 11 日
カテゴリ
ヘルプ センター および File Exchange で MATLAB Compiler についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!