Metodos Numericos en Matlab

UNIVERSIDAD POLITECNICA SALESIANA METODOS NUMERICOS NOMBRE: BRAYAN CARDENAS NIVEL: CUARTO G1 METODOS NUMERICOS EN MATLAB

Views 100 Downloads 7 File size 699KB

Report DMCA / Copyright

DOWNLOAD FILE

Recommend stories

Citation preview

UNIVERSIDAD POLITECNICA SALESIANA METODOS NUMERICOS NOMBRE: BRAYAN CARDENAS NIVEL: CUARTO G1 METODOS NUMERICOS EN MATLAB MENU DE OPCIONES

VISUALIZACION

 METODO DE LA BISECCION clc clear all disp('Ingrese la funcion de una variable independiente') f=input('Puede ser cualquier otro literal. f(x)=','s'); alto=0; while alto==0 a=input('Ingrese el intervalo inferior de la raiz: '); b=input('Ingrese el intervalo superior de la raiz: '); ea=subs(f,a); eb=subs(f,b); if ea*eb>0 disp('Los intervalos encierran cero o mas de una raiz'); disp('Ingrese otros intervalos'); else alto =1; end end alto=0; while alto==0 disp('Seleccione 1 para seleccionar el criterio de error relativo entre aproximaciones o 2 para seleccionar por numero') s=input('numero de interaciones: '); switch s case 1 epsilon=input('Ingrese maximo error relativo: '); alto=1; case 2 maxit=input('Ingrese maximo numero de iteraciones: '); alto=1; otherwise disp('Opcion no valida, Ingrese 1 o 2: ') end end it=1; alto=0; while alto==0 r=(a+b)/2; er=subs(f,r); if it>1 err=abs((b-a)/2*r); if s==1 if epsilon>=err alto=1; end end if s==2 if maxit1 disp(['El error relativo es: ' num2str(err)]) end disp(['La aproximacion esta entre: ' num2str(a) 'y' num2str(b)]) if er==0

alto=1; elseif eb*er>0 b=r; else a=r; end it=it+1; end VISUALIZACION

 METODO DE LA FALSA POSICION clc clear all disp('Ingrese la funcion de una variable independiente') f=input('Puede ser cualquier otro literal. f(x)=','s'); alto=0; while alto==0 a=input('Ingrese el intervalo inferior de la raiz: '); b=input('Ingrese el intervalo superior de la raiz: ');

ea=subs(f,a); eb=subs(f,b); if ea*eb>0 disp('Los intervalos encierran cero o mas de una raiz'); disp('Ingrese otros intervalos'); else alto =1; end end alto=0; while alto==0 disp('Seleccione 1 para seleccionar el criterio de error relativo entre aproximaciones o 2 para seleccionar por numero') s=input('numero de interaciones: '); switch s case 1 epsilon=input('Ingrese maximo error relativo: '); alto=1; case 2 maxit=input('Ingrese maximo numero de iteraciones: '); alto=1; otherwise disp('Opcion no valida, Ingrese 1 o 2: ') end end it=1; alto=0; while alto==0 ea=subs(f,a); eb=subs(f,b); r=b-((eb*(b-a))/(eb-ea)); er=subs(f,r); if it>1 err=abs((r-mr)/(r)); if s==1 if epsilon >= err alto=1; end end if s==2 if maxit1 disp(['El error relativo es: ' num2str(err)]) end disp(['La aproximacion esta entre: ' num2str(a) 'y' num2str(b)]) if er==0 alto=1; elseif eb*er>0 b=r; else a=r; end it=it+1; end

VISUALIZACION

 METODO DEL PUNTO FIJO

clc clear all disp('Ingrese la funcion de iteracion g(x) para encontrar la raiz de otra funcion') g=input('Puede ser otro literal. f(x)=','s'); r=input('Ingrese el punto inicial: '); alto=0; while alto==0 disp('Seleccione 1 para el criterio de error relativo o 2 para seleccionar por numero de iteraciones') s=input('escoja la opcion: '); switch s case 1 epsilon=input('Ingrese maximo error relativo: '); alto=1; case 2 maxit=input('Ingrese maximo numero de iteraciones'); alto=1; otherwise disp('Ocion no valida, Seleccione 1 o 2: ') end end it=1; alto=0; while alto==0 gr=subs(g,r);

err=abs((gr-r)/(gr)); if s==1 if epsilon >= err alto=1; end end if s==2 if maxit=err alto=1; end end if s==2 if maxit = err

alto =1; end end if s==2 if maxit