

















Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity
Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium
Esta página no es visible en la vista previa
¡No te pierdas las partes importantes!


















a=str2double(get(handles.edit1, 'String')); b=str2double(get(handles.edit2, 'String')); c=a+b; set(handles.edit3, 'String', num2str(c)) a=input('Ingrese a: '); b=input('Ingrese b: '); c=a+b; fprintf('c = a + b = %f \n',c)
function pushButton1_Callback(hObject, eventdata, handles) %de esta forma pido la variable a a=str2double(get(handles.edit1, 'String')); %de esta forma pido la variable b b=str2double(get(handles.edit2, 'String')); %hago la operación matemática c=a+b; %muestro el valor obtenido en la variable c en la caja de texto edit set(handles.edit3, 'String', num2str(c))
Que genera el mismo resultado que vimos con el código anterior (diapositiva 16)
clc,clear fun=@(x) x^3+7x-3sin(x)+exp(x)-7; Xo=input('Ingrese valor inicial: '); Xov(1)=Xo; Tol=input('Ingrese tolerancia: '); h=0.00001; errror=10; i=1; while errror>Tol Xov(i)=Xo; fx=fun(Xo); fxv(i)=fx; dfx=(fun(Xo+h)-fun(Xo-h))/(2*h); dfxv(i)=dfx; X1=Xo-fx/dfx; X1v(i)=X1; errror=abs(X1-Xo); errrorv(i)=errror; Xo=X1; i=i+1; end fprintf('Xo = %f \t fx = %e\t dfx = %5.6f \t X1 = %5.6f \t error = %g \n',[Xov;fxv;dfxv;X1v;errrorv])
Xo=input('Ingrese valor inicial: '); Xov(1)=Xo; Tol=input('Ingrese tolerancia: '); Xo=str2double(get(handles.edit1,'String')) Xov(1)=Xo; Tol=str2double(get(handles.edit2,'String'))
fprintf('Xo = %f \t fx = %e\t dfx = %5.6f \t X1 = %5.6f \t error = %g \n',[Xov;fxv;dfxv;X1v;errrorv])