Read a function in a GUI

2 views (last 30 days)
Hello. I'm working with a GUI and i don't how to introduce a function to be evaluate in my program. I started to use syms like a synonymous of inline, but i'm having problems with it. I hope you can help me. Note: I'm trying to solve a bisection method.
function BtnCalcular_Callback(hObject, eventdata, handles)
syms x;
Funcion=get(handles.EtxtFuncion,'String');
A=str2double(get(handles.EtxtInterA,'String'));
B=str2double(get(handles.EtxtInterB,'String'));
Tol=str2double(get(handles.EtxtTol,'String'));
e=100;
while e>=Tol
Xr=(A+B)/2;
e=Xr-A;
fXr=subs(Funcion,Xr);
fXa=subs(Funcion,A);
sig=(fXr)*(fXa);
if sig>=0
A=Xr;
else
B=Xr;
end
end
set(handles.ResRaiz,'String',num2str(A));

Accepted Answer

Walter Roberson
Walter Roberson on 17 Feb 2020
fXr = double(subs(Funcion,x,Xr));
fXa = double(subs(Funcion,x,A));

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!