Matalb compiled App crash on plotting while code version runs correctly

59 views (last 30 days)
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

Accepted Answer

dpb
dpb on 17 Dec 2025 at 12:21
Edited: dpb on 17 Dec 2025 at 15:41
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.
  5 Comments
dpb
dpb on 7 Jan 2026 at 12:48
Edited: dpb on 7 Jan 2026 at 14:18
"... would like to have a way to show customer that something is happening"
Use uiprogressdialog in AppDesigner/uifigure instead...
The following code is in the Update button callback function in one of my compiled apps and works just fine...note that the handle to the dialog is passed to the called functions so they can update the same control; if that argument is omitted, they know not to try for standalone use as those are external m-file functions in this case and I have other command line drivers that don't need the gui for batch operation.
% insert a progress dialog for grins...
h=uiprogressdlg(app.RestrictedAwardsUIFigure, ...
"Title",'Please Standby...',"Message",'Reading Billing',"Indeterminate","on");
% and finally, do the work...
[tBill,tPay,allBills]=readBilling(app.billQualFile,app.billSheet,app.accountingYear,app.semester,app.billUpdate,h);
h.Message='Writing Awards';
writeAwards(tBill,tPay,app.year,app.semester,app.accountingYear,app.awardQualFile,app.awardSheet,h);
h.Message='Update Complete';
pause(0.5)
close(h)

Sign in to comment.

More Answers (0)

Categories

Find more on Dialog Boxes in Help Center and File Exchange

Products


Release

R2024b

Community Treasure Hunt

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

Start Hunting!