You are on page 1of 3

UNIVERSIDAD CATÓLICA DE SANTA MARÍA

MECÁNICA COMPUTACIONAL II – MÉTODOS DE


INTEGRACION

APELLIDOS: Barrios Velarde

NOMBRES: Franciss Raúl

ESCUELA: Escuela Profesional de Ingeniería Mecánica, Mecánica


Eléctrica y Mecatrónica

GRUPO: 04

DOCENTE: Ingeniero Christiam Guillermo Collado Oporto

AÑO: 2017
1. METODO DE INTEGRACION POR TRAPECIOS

clc
clear all
close all

f=input('Ingrese la funcion: ','s');


a=input('Ingrese el limite inferior: ');
b=input('Ingrese el limite superior: ');
nr=input('Ingrese el numero de trapecios: ');

h=(b-a)/nr;
A=0;

for(i=a:h:b-h)

x=i;
fi1=eval(f);
x=i+h;
fi2=eval(f);
A=A+((fi1+fi2)*h)/2;

s=[i i+h];
y=[fi1 fi2];

plot([s(1) s(1)],[0 y(1)],'b');


hold on
plot([s(1) s(2)],[y(1) y(2)],'b');
hold on
plot([s(2) s(2)],[0 y(2)],'b');
hold on
fill([s(1) s(1) s(1) s(2) s(2) s(2) s(2) s(1)],[0 y(1) y(1) y(2) y(2) 0 0 0], 'b')
hold on
end

x=linspace(a,b,1000);
y2=eval(f);
plot(x,y2,'r');
hold on
grid on
2. METODO DE INTEGRACION POR PUNTO MEDIO

clc
clear all
close all

f=input('Ingrese la funcion: ','s');


a=input('Ingrese el limite inferior: ');
b=input('Ingrese el limite superior: ');
nr=input('Ingrese el numero de rectangulos: ');

h=(b-a)/nr;
A=0;

for(i=a:h:b-h)

x=i;
fi=eval(f);
A=A+(fi*h);

s=[i-(h/2) i+(h/2)];
y=[fi fi];

plot([s(1) s(1)],[0 y(1)],'b');


hold on
plot([s(1) s(2)],[y(1) y(2)],'b');
hold on
plot([s(2) s(2)],[0 y(2)],'b');
hold on
fill([s(1) s(1) s(1) s(2) s(2) s(2) s(2) s(1)],[0 y(1) y(1) y(2) y(2) 0 0 0], 'b')
hold on
end

x=linspace(a,b,1000);
y2=eval(f);
plot(x,y2,'r');
grid on

You might also like