How to solve error in compiling a stand alone application

45 vues (au cours des 30 derniers jours)
okoth ochola
okoth ochola le 25 Oct 2024 à 5:37
Modifié(e) : Hitesh le 25 Oct 2024 à 10:48
Hello, I was trying to compile a standalone application in matlab but I ran into some problems. May I inquire a couple of questions.
i) When I was compiling, the programs compiles but when it reaches packaging, an error occurs as shown in the screenshots. Especially when unchecks "Do not diplay the windows command shell.
ii) suppoose I have succesfully compiled the programme, I have noticed previously that compiled programs from matlab, only does its work once, after it has succesfully executed and results generated, the application automatically closes. My question is, is there a way I can instruct the stand alone appliication not to quit, such that I can be able to do more than one runs without having to start again. That is, onse a task is completed, I can promt it to accept another set of inputs without having to start the application again?
... console" in the advanced setting before compiling. What can be causing this? Please help.

Réponse acceptée

Hitesh
Hitesh le 25 Oct 2024 à 10:47
Modifié(e) : Hitesh le 25 Oct 2024 à 10:48
Hi okoth ochola,
The answers to both of your queries are as follows:
  1. The error "Creating installer zip archive due to contents exceeding maximum Windows program size" you are encountering is not an error but a new feature in R2019a on Windows OS. The message in red is not error but warning i.e. the expected results and xxx.zip works fine. For more information regarding this warning, refer to the below MATLAB Answers: https://www.mathworks.com/matlabcentral/answers/782413-why-do-i-get-error-of-exceeding-maximum-windows-program-size-when-i-compile-matlab-code-to-exe-file
  2. To keep your standalone application open for multiple runs without closing, you can modify your MATLAB script or function to incorporate a loop that allows for repeated execution. Refer to the below code as an example in which the app will keep on asking for the number to get the factorial until the user prompts for exit.
function calFact()
while true
% Prompt user for input
userInput = input('Enter a positive integer to calculate its factorial (or type "exit" to quit): ', 's');
% Check for exit condition
if strcmpi(userInput, 'exit')
disp('Exiting application...');
break;
end
% Convert input to a number
number = str2double(userInput);
% Validate input
if isnan(number) || number < 0 || floor(number) ~= number
disp('Please enter a valid positive integer.');
continue;
end
% Calculate factorial
result = factorial(number);
% Display result
fprintf('The factorial of %d is %d.\n', number, result);
end
end
calFact();
For more information on, "Create Standalone Application from MATLAB Function" using programmatically, refer to the following MATLAB documentation:

Plus de réponses (0)

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by