function  retval = trapz(y)
% usage: retval = trapz(y)
% description: Returns result of trap applied to vector of values
% at equally spaced nodes, minus the factor of width of subintervals
% To get area, multiply this result by subinterval width.

nn = length(y);
retval = sum((y(1:nn-1)+y(2:nn))/2);

