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

2 visualizaciones (últimos 30 días)
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 comentarios
Walter Roberson
Walter Roberson el 18 de Ag. de 2024
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 el 18 de Ag. de 2024
I am sorry for my mistake Walter. I updated my question, see if you got anything? thank you.

Iniciar sesión para comentar.

Respuestas (1)

halleyhit
halleyhit el 19 de Ag. de 2024
Editada: halleyhit el 19 de Ag. de 2024
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 comentarios
Amirreza Farzaneh
Amirreza Farzaneh el 19 de Ag. de 2024
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 el 19 de Ag. de 2024
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.

Iniciar sesión para comentar.

Categorías

Más información sobre Code Generation en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by