Error in compiled Program
显示 更早的评论
Hello Matlabers, I have a problem in my program created in MATLAB R2015a. I coded a program about Newton's cooling law. It works in Matlab Perfectly. After I compiled this program. I opened Test Release and start the .exe file in Windows 10. GUI Appears after I press the calculate button program has created blink sound. I searched cause of that sound and command prompt of windows shows following errors.
Error in soguma>pushbutton1_Callback (line 193)
Error in gui_mainfcn (line 95)
Error in soguma (line 42)
Error in @(hObject,eventdata)soguma('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
What is the reason of that ERROR.
I uploaded files in my drive. The link is: https://drive.google.com/file/d/0B0cYUACDfN-1TEJ5cmlZcy1TYjQ/view?usp=sharing
Thanks for your help.
1 个评论
Image Analyst
2015-12-30
Isn't there more? Usually it gives the reason for the error, something more descriptive than just "Error while evaluating UIControl Callback" but an actual reason, for example some variable is being used before it's been defined, or index out of range, or something.
回答(2 个)
Image Analyst
2015-12-30
0 个投票
You're probably missing a file. Have you seen the FAQ: http://matlab.wikia.com/wiki/FAQ#My_standalone_executable_won.27t_run_on_the_target_computer._What_can_I_try.3F
Walter Roberson
2015-12-31
Your code calls upon dsolve(), which is part of the Symbolic Toolbox. Nothing in the Symbolic Toolbox can be compiled.
What you need to do in a case like this is do the dsolve() symbolically at the MATLAB level, outside of this program.
syms Tc T(t) k Tilk
formula = dsolve(diff(T(t))== -k*(T(t)-Tc),T(0)==Tilk);
Now write it to a file as a MATLAB function:
matlabFunction(formula, 'Vars', [Tc, k, t, Tilk], 'File', 'sicaklik');
Now you go into your code and remove the "syms" and calculation of the dsolve and so on, and instead call upon sicaklik() -- but passing in one more parameter than you do in the existing code, with the extra parameter being the numeric value of Tilk
By the way, the formula comes out as
sicaklik = @(Tc, k, t, Tilk) Tc + exp(-k*t) .* (Tilk-Tc);
and you could just hard-code that.
类别
在 帮助中心 和 File Exchange 中查找有关 Code Performance 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!