%% pwpolmin.m is designed to be called by pwpolfit.m and is used to
%% determine the coefficients that best minmise the weighted least
%% fit of the n'th order polynominal to the data.
%% 

function chi=pwpolmin(c,xv,yv,wt)

chi=sum(wt.*(yv-polyval(c,xv)).^2);