Why my standalone app is not working

50 vues (au cours des 30 derniers jours)
okoth ochola
okoth ochola le 1 Août 2023
Commenté : Image Analyst le 1 Août 2023
Hi there, have been trying to experiment with building a standalone application in matalab. I tried to convert this code attached below. I needed the app to load data from a file in Excell using a path loaded by an end user. Is this possible? Have tried to compile the code, indeed the application is compiled and installed as standalone app but when oppenedit just disapperas. Please someone help me. Am determined to learn matlan programming language.
Filepath1=input('enter the file path to the excel workbook where your data is\n');
Sheetnumber1=input('enter the sheet number conntaining all the orders done over the period considered\n');
Sheetnumber2=input('enter the sheet number conntaining all the paid oders\n');
Sheetnumber3=input('enter the sheet number conntaining the amount corresponding to each order\n');
filename=input('Enter the File Name:Make sure this file has been created in your desktop\n');
A = xlsread(Filepath1,Sheetnumber1)
B = xlsread(Filepath1,Sheetnumber2)
Amount = xlsread(Filepath1,Sheetnumber3)
%B=[3 4 5 1 2 3 4 5 6 7 8 9 3 4 2 1 3]';
%A=[13 4 5 1 2 3 14 5 16 7 8 9 3 4 2 1 3 98 100]';
C= ismember(A,B);
selectedRowsLogicalIndices1 = C == 1;
selectedRowsLogicalIndices0 = C == 0;
Paid=A(selectedRowsLogicalIndices1)
NotPaid=A(selectedRowsLogicalIndices0)
Total_Amount=sum(Amount);
Amount_Paid=sum(Amount(selectedRowsLogicalIndices1));
Amount_NotPaid=sum(Amount(selectedRowsLogicalIndices0));
Balance=Amount_NotPaid;
D=[A Amount C];
idx = D(:,3);
%Convert D to a categorical array
D = categorical(D);
str = categorical(["Notpaid", "paid"]);
D(:,4) = str(idx+1)
Order_Number=D(:,1);
Amount=D(:,2);
Logical=D(:,3);
Payment_status=D(:,4);
Table=table(Order_Number,Amount,Logical,Payment_status)
Table2=table(Total_Amount,Amount_Paid,Amount_NotPaid,Balance)
a=3;
writetable(Table,filename,'Sheet',1,'Range','A1')
writetable(Table2,filename,'Sheet',2,'Range','A1')

Réponse acceptée

Dirk Engel
Dirk Engel le 1 Août 2023
I was able to compile and run your application with MATLAB R2019b.
Make sure to disable "Do not display Windows Command Shell" under "Additional runtime settings", as you want your app to be a console application.
  3 commentaires
Dirk Engel
Dirk Engel le 1 Août 2023
Do you mean after the app runs to completion? You could add another input() command at the end which just waits until the user presses Enter.
input('Press Enter to close the app\n', "s");
Image Analyst
Image Analyst le 1 Août 2023
@Dirk Engel I guess @okoth ochola got it figured out because he accepted your answer. (Not sure if he ever even saw mine.)

Connectez-vous pour commenter.

Plus de réponses (1)

Image Analyst
Image Analyst le 1 Août 2023
When you double click the icon and the application just flashes and goes away, or never appears at all, chances are you installed it on a target computer that does not have the same MCR (MATLAB Component Runtime library) installed. To check this, get a console window (DOS/CMD prompt in Windows) and go to the folder where your executable app is installed. Then type in the name of your app and hit Enter. NOW the errors should appear in the console window and remain so that you can see them. Most likely it will say that you don't have the right version of MCR installed. If you double click the icon from the desktop of File Manager, this window, along with any errors displayed in it, just vanish immediately so you can't see them. That's why you need to run your app from a console window. That's just to see what the problem is. Once it's working, you can go back to clicking on the icon and don't need to use the console window anymore to run your app.
For more info, and for other possible causes, see the FAQ:

Catégories

En savoir plus sur Package and Share Apps dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by