MATLAB: Does the code have an error

guide

Matlab works fine but when I do an executable file this button does not work in my program is the only one that does not work is the one with the longest code I can not understand because it is the only button that does not work when I convert it to executable file. I repeat in matlab if the code of this button works and it does not mark error but when I use this button in the ejectable it does not work
function pushbutton3_Callback(~, ~, handles)
syms x %variable simbolica x
f=get(handles.edit8,'string');
xl=str2double(get(handles.edit3,'string'));
xu=str2double(get(handles.edit5,'string'));
tol=str2double(get(handles.edit4,'string'));
E=100;
xa=100;
i=0;
while(tol<E)
xr=(xl+xu)/2;
fxl=subs(f,x,xl);
fxr=subs(f,x,xr);
m=fxl*fxr;
if(m)<0
xu=xr;
else
xl=xr;
end
E=abs(xr-xa);
xa=xr;
i=i+1;
end
xr;
vpa(E,5)
set(handles.edit6,'string',xr);
set(handles.edit9,'string',E);
% --- Executes on button press in pushbutton4.

Best Answer

It is never possible to compile anything from the Symbolic Toolbox into an executable.
It is also not possible to use eval() or evalc() or inline(). str2func() can only be used at compile to for constant expressions, which then compiled into fixed functions.
It is not possible in a compiled executable to dynamically create a symbolic function or an anonymous function based upon user input.
The only work-around for this is for you to create your own expression string parser that analyzes the user input in terms of functionality you have already compiled in, starting with numeric values and doing operations on them according to what your program understands of the string. See https://www.mathworks.com/matlabcentral/fileexchange/24026-growing-a-compiler?focused=6785573&tab=example