Compiled exe app doesn't work on a function used within another function
2 ビュー (過去 30 日間)
古いコメントを表示
So I have an app developed by MATLAB app designer. I have put my main backend code in a function and call that function on button press.
Here is my problem: While running in app designer everything is fine, but when I compile it as a stand-alone exe file and install it, the code doesn't work properly. So I used messages in different parts of code to debug it and I find out that it stops as soon as it reaches first function used in the main function. Here is a demonstration of my main code, note that this is the main function called by app designer:
function maincode
x = 1;
y = 2;
z = secondfunction(x,y);
end
and my secondfunction is saved in another .m file (which I include in additional files before packaging)
function [sum] = secondfunction(inputArg1,inputArg2)
syms x
eqn = inputArg1*x + inputArg2 == 0;
sum = solve(eqn,x);
end
UPDATE: I debuged it further and now I am 100% sure that it has to do something with "syms" and "solve".
2 件のコメント
Walter Roberson
2024 年 8 月 18 日
and my secondfunction is saved in another .m file
You appear to have accidentally named your second function maincode .
In theory, functions are to be invoked according to the file name, not according to the function line name, so in theory as long as your second function file name was secondfunction.m the code should have worked. But it would not entirely surprise me if MATLAB gets confused by this situation.
回答 (1 件)
halleyhit
2024 年 8 月 19 日
編集済み: halleyhit
2024 年 8 月 19 日
In your second function, you are using syms, which is from Symbolic Math Toolbox. As shown in doc:
It is not supported in Compiler workflow.
4 件のコメント
Steven Lord
2024 年 8 月 19 日
Either solve them symbolically then generate a MATLAB function to evaluate that solution without using Symbolic Math Toolbox and use the generated function in your application (as shown on this documentation page) or switch to solving them numerically using the functions included in this documentation category.
参考
カテゴリ
Help Center および File Exchange で Code Generation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!