Read a function in a GUI
조회 수: 2 (최근 30일)
이전 댓글 표시
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));
댓글 수: 0
채택된 답변
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!