Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

% --- Executes during object creation, after setting all properties.

function listbox1_CreateFcn(hObject, eventdata, handles)


% hObject
handle to listbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns
called
% Hint: listbox controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

% --- Executes on button press in pushbutton1.


function pushbutton1_Callback(hObject, eventdata, handles)
f=get(handles.edit1,'string');
a=str2num(get(handles.edit2,'string'));
b=str2num(get(handles.edit3,'string'));
n=str2num(get(handles.edit4,'string'));
%Grafica
L='Iteraciones';
x=a-1:0.01:b+1;
y=eval(f);
plot(x,y)
grid on
i=1;
while i<=n
x1=(a+b)./2;
x=a;
f1=eval(f);
x=x1;
f2=eval(f);
if f1.*f2<0
b=x1;
else
a=x1;
end
L=strvcat(L,num2str([i x1]));
set(handles.listbox1,'string',L);
i=i+1;
end
x=x1;
fr=eval(f);
set(handles.edit5,'string',fr);

% --- Executes on button press in pushbutton2.


function pushbutton2_Callback(hObject, eventdata, handles)
set(handles.edit1,'string',' ');
set(handles.edit2,'string',' ');
set(handles.edit3,'string',' ');
set(handles.edit4,'string',' ');
set(handles.edit5,'string',' ');
set(handles.listbox1,'string',' ');
plot(0,0)
pushbotton3
close

You might also like