function T=trapez(x,y) n=length(x) h=x(2)-x(1) s=y(1)+y(n) for i=2:n-1 s=s+2*y(i) endfor T=h/2*s endfunction