0

I have created an app using Matlab app designer and deployed it with these settings: enter image description here The problem is when I run the app while on Matlab, the app runs perfectly but after I deployed it into a standalone app there are two sections which is not showing the result the output when I run the app from the Matlab directly looks like this: enter image description here while the output when I run from the standalone app looks like this: enter image description here the code for the calculate button looks like this:

dm=app.MinimumDemandEditField.Value;
dM=app.MaximumDemandEditField.Value;
tm=app.MinimumLeadTimeEditField.Value;
tM=app.MaximumLeadTimeEditField.Value;
r1=app.ReorderLevelEditField.Value;
Et = 0.5*(tm+tM);
vart = 1/12*(tM-tm)^2;
Ed = 0.5*(dm+dM);
vard = 1/12*(dM-dm)^2;
ED = 1/4*(dm+dM)*(tm+tM);
varD = 1/144*(3*(dm+dM)^2*(tM-tm)^2+3*(dM-dm)^2*(tm+tM)^2+(tM-tm)^2* 
(dM-dm)^2);
gt = 1/(tM-tm);
fd = 1/(dM-dm);
fD = 1/((dM-dm)*(tM-tm));
f1=app.FixedCostEditField.Value;
c1=app.VariableCostEditField.Value;
h=app.HoldingCostEditField.Value;
s=50*c1;
app.ShortageCostEditField.Value = s
A1=c1+(h/Ed)*(r1-ED);
A2=fD*(r1*(tM-tm)*log(r1/(tM*dm))-(r1^2/dM)+(r1*tM)- 
(r1*tm)*log((dM*tM)/r1)-Et);
syms x;
f=(x-r1)*fD;
EB= double(int(f,r1,dM*tM));
A3=Ed*f1+h*Ed*(fD*((r1^2*tm/2)-(dm*r1/2)*(tM^2-tm^2)+(dm^2/6)*(tM^3- 
tm^3)-((r1^3/6*dM)-(dM*r1*tm^2/2)+(dM^2*tm^3/6)))+(fD/18)*(tM^3- 
tm^3)*(dM^3-dm^3)-r1*ED+Ed*s*EB);
Q=(1/h)*((Ed*(A1+h*A2-c1)+(h*(ED-r1))));
Eoh=fD*((((r1^3*tM)/2)-(((dm*r1)/2)*(tM^2-tm^2))+(((dm^2)/6)*(tM^3- 
tm^3))-((r1^3)/(6*dM))-((dM*r1*tm^2)/2)+((dM^2*tm^3)/6))+ 
((Q^2)/2*Ed)-(Q*ED/Ed)+((fD/(18*Ed))*((tM^3-tm^3)*(dM^3-dm^3)))+ 
(Q*r1/Ed)-(r1*ED/Ed));
TC= f1+c1*Q+h*Eoh+s*EB;
app.QOptimalEditField.Value = Q
app.TotalCostEditField.Value = TC
Adriaan
  • 17,741
  • 7
  • 42
  • 75
  • Ok, you’ve presented the problem. Now what is the question? “Solve my problem” is not a question. Also, if you are hoping someone else will debug your code for you, did you consider that that person might need to see (and run) the code to be able to debug it? – Cris Luengo Jan 28 '19 at 14:16
  • I'm terribly sorry @CrisLuengo what I think maybe I did the deploy in a wrong way or another technical error because the code runs okay in the Matlab – Kevin Renard Jan 28 '19 at 14:19
  • This code won't run as-is; e.g. the declarations of `varD` and `A2`, `A3` have line-breaks in them which will break the code. Either there shouldn't be a line break, or there should be ellipses, `...` to continue the line. Please also consider some kind of commentary and empty lines, as all those 2 letter variables are a complete spaghetti to me. As to the post itself: it's still not clear A) what the problem is, and B) what you want our help with. I suspect you want us to fix your 'calculate' button, but please explicitly mention that to prevent us from groping in the dark – Adriaan Jan 28 '19 at 14:24
  • Unrelated advice: do think of better variable names. Having both `tm` and `tM` is **very** confusing. Also `A1, A2, A3` isn't very descriptive. Imagine someone else reading this code, would they understand anything? I'd go with more descriptive variable names, e.g. `tmin, tmax`, even if they might be a bit longer, and have a comment on the declaration line as to what this is. Makes it easier for you as well to read your own code in a few months time. – Adriaan Jan 28 '19 at 14:30
  • 1
    Thank you for the advice @Adriaan I'll try your suggestion about the variable naming and the line breaks problem. Thanks a lot for the advice since I'm still learning about coding and Matlab – Kevin Renard Jan 28 '19 at 14:38
  • 1
    Try running your deployed app from a DOS prompt to see if any errors are thrown, and I **second** the more descriptive variable names mentioned by @Adriaan. I remember reading somewhere "your write a variable name once but read it 1000 times". – matlabgui Jan 28 '19 at 14:59
  • Indeed: regarding naming conventions and such. You should not write code for the computer but for other people. Try to write code in a way that it is easy to read. When you look at your code in a few months you won’t remember much of what you were thinking when you wrote it, and it’ll be as hard to read for you then as it is for us now. – Cris Luengo Jan 28 '19 at 15:39

0 Answers0