Matalb compiled App crash on plotting while code version runs correctly
21 views (last 30 days)
Show older comments
Hello,
I have an App which works well when running it from Matlab and I compiled it as a standalone application (it is intended to be delivered to a customer). But then the compiled App starts well (basically at opening it draws an Earth) and then i try to read a set of files with data and after some computation it is supposed to draw iso-contours (done by contourf) but instead it closes abruptally - no message in the log, no clue.
Any idea how to progress on that ?
Thanks in advance,
Bertrand
0 Comments
Answers (1)
dpb
about 4 hours ago
Edited: dpb
36 minutes ago
This can be a bear, indeed...
The first place to look is to be sure you can find any input files needed; figuring out where the installer puts them can be a real pain; where things are when compiled is not where they are when running directly. Look on the installed machine for any such files to be sure you know where they are.
I wrote the following logging routine and then instrumented the app extensively to report where it was and when if completed each function call. For debugging, compile with the option to open the console as well so it will be visible and then the error messages can be seen until close the app.
function displayprogress(app,varargin)
% writes function, line number to command line if debug on
if app.debugFlag
S=dbstack; % call stack struct
ix=find(matches(strip(string(strvcat(S(:).name))),'displayprogress'))+1; % find who called us
%out=sprintf('Function: %s Line: %d, %s',fncn,line,msg);
if nargin>1, msg=varargin(1); else msg=''; end
out=sprintf('Time: %7.4fs File: %s Name: %s Line: %d %s ',toc,S(ix).file,S(ix).name,S(ix).line,msg{:});
disp(out)
end
end
I added a menu item under an "Environment" menu in the app to be able to toggle the debug flag.
This turned out to be invaluable in tracking down a couple of elusive errors that I couldn't reproduce outside the compiled app.
2 Comments
dpb
40 minutes ago
"am not sure to know how to compile with the option to open the console"
If you build inside AppDesigner open the Additional Setting and there's a checkbox to not create the Windows Command Window that is checked by default. Uncheck it. I don't recall at the moment the actual switch...
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!