フィルターのクリア

xlwrite not writing when complied using Application Compiler

1 回表示 (過去 30 日間)
JR
JR 2015 年 9 月 21 日
回答済み: Image Analyst 2015 年 9 月 21 日
javaaddpath('jxl.jar');
javaaddpath('MXL.jar');
import mymxl.*;
import jxl.*;
filename = 'Test.xls';
data = {A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R}
xlwrite('./Test.xls',data);
When I use this code in MATLAB R2014b the test.xls is created in the folder where the .m is. There is more code in the .m file, but I have not included as this is just defining variables.
When I compile this using the Application Compiler, the xls file is not created. I have included all files that I got in the xlwrite download, when I compiled. I also included the ./ to indicate that the xls should be written in the folder the app is. But still no file is written...
Can anyone advise me where I am going wrong when I open the app after compiling please?

回答 (2 件)

Kirby Fears
Kirby Fears 2015 年 9 月 21 日
If no error is being thrown by xlwrite, chances are your current directory at runtime is not where you think it is.
You could add "pwd" to the line above xlwrite to see what the current directory is at runtime.
  3 件のコメント
Kirby Fears
Kirby Fears 2015 年 9 月 21 日
Can you show how you are executing the compiled code and what the command line output is?
JR
JR 2015 年 9 月 21 日
Executing in MATLAB or outside of MATLAB?

サインインしてコメントする。


Image Analyst
Image Analyst 2015 年 9 月 21 日
The real executable is not where you put the executable, but, at least in Windows, in some secret hidden folder. Not sure about on the Mac like you have. Anyway, that's why you should never NOT use a specific folder when reading and writing files from an executable. You should always specify exactly where you want to read or write the file.
For what it's worth, I've given code below to figure out where the executable actually lives, though I think it only works for Windows.
% Returns the folder where the compiled executable actually resides.
function [executableFolder] = GetExecutableFolder()
try
if isdeployed
% User is running an executable in standalone mode.
[status, result] = system('set PATH');
executableFolder = char(regexpi(result, 'Path=(.*?);', 'tokens', 'once'));
% fprintf(1, '\nIn function GetExecutableFolder(), currentWorkingDirectory = %s\n', executableFolder);
else
% User is running an m-file from the MATLAB integrated development environment (regular MATLAB).
executableFolder = pwd;
end
catch ME
errorMessage = sprintf('Error in function %s() at line %d.\n\nError Message:\n%s', ...
ME.stack(1).name, ME.stack(1).line, ME.message);
uiwait(warndlg(errorMessage));
end
return;

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by