Compiled exe app doesn't work on a function used within another function

조회 수: 6 (최근 30일)
Amirreza Farzaneh
Amirreza Farzaneh 2024년 8월 18일
댓글: Steven Lord 2024년 8월 19일
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
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.
Amirreza Farzaneh
Amirreza Farzaneh 2024년 8월 18일
I am sorry for my mistake Walter. I updated my question, see if you got anything? thank you.

댓글을 달려면 로그인하십시오.

답변 (1개)

halleyhit
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
Amirreza Farzaneh
Amirreza Farzaneh 2024년 8월 19일
Yes I know that, but it was a placeholder. My actual equations are ode and pde. Any way to compile them using syms? Or alternatives?
Steven Lord
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.

댓글을 달려면 로그인하십시오.

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by