function [x,w,varargout] = traprule(n,a,b)
%
% Generate nodes and weights for
% the trapezoidal rule on [a,b].
% Note that x is a column vector
% and w is a row vector.  Note also
% that n is the number of points, not
% the number of intervals, which is n-1.
%
nw = n;
x = linspace(a,b,nw).';
w = repmat((b-a)/(nw-1),1,nw);
w(1) = w(1)/2;
w(end) = w(end)/2;
if nargout==3
    varargout{1} = nw;
end