How could I write this code in another way? Do you need the str2double? I put it to get the numerical value
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;endxr;vpa(E,5)set(handles.edit6,'string',xr);set(handles.edit9,'string',E);% --- Executes on button press in pushbutton4.
Best Answer