0

I developed a Matlab GUI program which it has four editbox & one pushbutton; my application works properly when I run it with Matlab software, but after converting it to exe file (standalone), the pushbutton doesn't work, means it doesn't show the output in 'Result' editbox. so what's the problem? here is my pushbutton code:

function btnCal_Callback(hObject, eventdata, handles)
a=str2num(get(handles.txbLow,'string'));
b=str2num(get(handles.txbHi,'string'));
f=get(handles.txbForm,'string');
x=0.5*((b-a)*(-1*(3/5)^0.5)+b+a);
g=subs(f,'x',x);
sum=(g)*(5/9);
x=0.5*(b+a);
g=subs(f,'x',x);
sum=sum+(g)*(8/9);
x=.5*((b-a)*((3/5)^.5)+b+a);
g=subs(f,'x',x);
sum=sum+g*(5/9);
result=sum*((b-a)/2);
set(handles.txbResult,'string',result);
HebeleHododo
  • 3,620
  • 1
  • 29
  • 38
  • Do you mean that totally nothing happens if you press the button? Can you make the exe do anything at all? Are you using the exe on the same computer as you are using Matlab? – Dennis Jaheruddin Jan 03 '13 at 12:20

2 Answers2

0

First, I'm a bit confused with

result=sum*((b-a)/2);   % "result" is numeric
set(handles.txbResult,'string',result);   % "result" should be string

Next, just as a hint. To "debug" your deployed code, try to launch your exe from cmd, in this case, you would see some messages there, and they might help.

Igor
  • 1,359
  • 19
  • 34
0

your 'result' needs to be either double, char, or cell. You can do this by e.g.

set(handles.txbResult,'String',char(result);

However: I got exactly the same problem with a very similar code on my Mac. The Application runs very well if executed via "run" in Matlab, but once I compiled it to a standalone.app one hears this error-sound when pushing the button, nothing else is happening.

Trying to set the 'result' variable as "global" helped solving this problem for another program that I wrote (a very simple "calculate a+b" thing), but not for the mentioned slightly more complex code (3 instead of 2 inputs and 3 outputs instead of 1).

The super simple code which is working:

function pushbutton1_Callback(hObject, eventdata, handles) %the button to push
...some code...
global statText;
set(statText,'String',char(output));

function text1_CreateFcn(hObject, eventdata, handles) %the outputfield
global statText;
statText = hObject;
swiknaba
  • 83
  • 1
  • 7