  function numI = CompQNC(fname,a,b,m,n)
%
% Pre:
%   fname    string that names an available function of the
%            form f(x) that is defined on [a,b]. f should
%            return a column vector if x is a column vector.
%     a,b    real scalars 
%       m    integer that satisfies 2 <= m <=11
%       n    positive integer
%
% Post:
%    numI    the composite m-point Newton-Cotes approximation of the 
%            integral of f(x) from a to b. The rule is applied on
%            each of n equal subintervals of [a,b].
% 
   Delta = (b-a)/n;
   h = Delta/(m-1);
   x = a+h*(0:(n*(m-1)))';  
   w = WNC(m);
   x = linspace(a,b,n*(m-1)+1)';
   f = feval(fname,x);
   numI = 0; 
   first = 1; 
   last = m;
   for i=1:n
      %Add in the inner product for the i-th subintegral.
      numI = numI + w'*f(first:last);
      first = last;
      last = last+m-1;
   end 
   numI = Delta*numI;
  
