Contoh Program Mencari Luas  dengan 
Metode Trapesium	n	x(i)	
clear;
clf;
a=-2;
b=3;
%Mencari luas f(x) dengan sb.x dalam 
%interval [a,b]
k(1)=1
Luas(1)=0.5*(b-a)*fungsi(a)+fungsi(b)
for n=2:25
   dx=(b-a)/n;
   for i=1:(n-1)
      fxi(i)=dx*fungsi(a+(i*dx));
   end
   fxitot=sum(fxi);
   k(n)=n;
   fa=0.5*dx*fungsi(a);
   fb=0.5*dx*fungsi(b);
   Luas(n)=fa+fb+fxitot
end
plot(k,Luas), grid on
   
% Fungsi-nya
function fx=fungsi(x)
fx=abs(x^2-x-6);	1	0	
	2	15.6250	
	3	18.5185	
	4	19.5313	
	5	20.0000	
	6	20.2546	
	7	20.4082	
	8	20.5078	
	9	20.5761	
	10	20.6250	
	11	20.6612	
	12	20.6887	
	13	20.7101	
	14	20.7270	
	15	20.7407	
	16	20.7520	
	17	20.7612	
	18	20.7690	
	19	20.7756	
	20	20.7813	
	21	20.7861	
	22	20.7903	
	23	20.7940	
	24	20.7972	
	25	20.8000	

Luas =

  Columns 1 through 7 

         0   
15.6250   
18.5185   
19.5313   
20.0000   
20.2546   
20.4082

  Columns 8 through 14 

   20.5078
   20.5761
   20.6250
   20.6612
   20.6887
   20.7101
   20.7270

  Columns 15 through 21 

   20.7407
   20.7520
   20.7612
   20.7690
   20.7756
   20.7813
   20.7861

  Columns 22 through 25 

   20.7903
   20.7940
   20.7972
   20.8000