Read a function in a GUI

조회 수: 2 (최근 30일)
Alejandra Chávez
Alejandra Chávez 2020년 2월 16일
댓글: Alejandra Chávez 2020년 2월 17일
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));

채택된 답변

Walter Roberson
Walter Roberson 2020년 2월 17일
fXr = double(subs(Funcion,x,Xr));
fXa = double(subs(Funcion,x,A));
  댓글 수: 1
Alejandra Chávez
Alejandra Chávez 2020년 2월 17일
Thank you so much :)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by