Some button in standalone app not working after being compiled (although code working well)

4 Ansichten (letzte 30 Tage)
Hi Community,
As in the title, we made an app using Matlab 2019b and I compiled it to be a standalone app.
Although the code works well (in Matlab 2019b), a certain button doesn't work after being compiled to be a standalone app. That is, if I'm using code, I push the button and the corresponding function runs; But if I use the standalone app I generated and push the button, nothing just happen.
I've checked that
  • My Matlab runtime is R2019b 9.7.0.1737446 (the runtime was installed while I'm installing the app)
  • I do included all files in the list for compiling.
Any hint for the potential reason is high appreciated!
  3 Kommentare
Bowei Li
Bowei Li am 10 Mai 2022
Bearbeitet: Bowei Li am 10 Mai 2022
Hi steven, when button pushed it will execute code like the following, where Function 1, 2, 3 are all user-defined functions (can't show as they are confidential). Function 1, 2, 3 and all user-defined functions they used are all being packaged.
When I push it, I didn't get any error message but a "pin" sound.
function ButtonPushed(app, event)
if isempty(app.AAA)
uialert(app.AAAUIFigure,'Warning Message','Missing data');
return
end
[Outputs1] = Function1(Inputs1);
if Outputs1
uialert(app.AAAUIFigure, 'Warning Message', 'Missing files');
return
end
try
[Outputs2] = Function2(Inputs2);
[Outputs3] = Function3(Inputs3);
% Success message
msg = {'Success.'};
catch
% Success message
msg = {'Failed.'};
end
end
Image Analyst
Image Analyst am 10 Mai 2022
Set breakpoints and see where it gets to. Also, why are you assigning msg and never using it? Can you attach the whole .mlapp file?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Steven Lord
Steven Lord am 10 Mai 2022
I believe if you launch the application from a system command prompt (Command Prompt on Windows, for example) rather than double-clicking the app icon in File Explorer then any error messages that the app generates will show in that prompt.
If you try it and that doesn't, you may want to send the app to Technical Support and work with them to determine what function or functions you're using that are not being packaged into the app.
Alternately for debugging purposes you could wrap those Function* calls in try / catch blocks and show a uialert window with the error information from the catch block. This may indicate the cause of the problem and lead to a workaround or solution. See the code below for an example of what I'm thinking using fprintf (since MATLAB Answers can't display a uialert window.)
try
x = (1:2)+(1:3);
fprintf("Success!\n")
catch ME
fprintf("Failure! Error message was:\n%s", ME.message)
end
Failure! Error message was: Arrays have incompatible sizes for this operation.
Or if that's your actual code (with some lines elided) I did note one problem on closer inspection:
%{
[Outputs1] = Function1(Inputs1);
if Outputs
%}
You assign the Outputs1 but then test Outputs (no 1.)
  1 Kommentar
Bowei Li
Bowei Li am 10 Mai 2022
Thanks a lot Steven! I tried what you said (try catch and show the error) and found the reason is that the prograrm is trying to open and write in a file but doesn't have permission to do so.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Package and Share Apps finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by