function t = comptrap(f,a,b,n) % % DESCRIPTION : % Returns the value of the composite trapezoidal rule to % approximate the integral of f over [a,b], using n intervals. % h = (b-a)/n; % step size t = (feval(f,a)+feval(f,b))*h/2; % for n = 1 for i=1:n-1 t = t+h*feval(f,a+i*h); end