www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@xreglinear/quicklsq.m
function [mout,OK]= leastsq(m,x,y,Wc); % xreglinear/LEASTSQ least squares estimate of model % Copyright 2000-2004 The MathWorks, Inc. and Ford Global Technologies, Inc. if nargin<4 Wc=[]; end J= CalcJacob(m,x); if ~isempty(Wc) J= Wc*J; y= Wc*y; end % rough check [Q,R,OK]= xregqr(J); if OK % Calculate coefficients m.Beta= zeros(size(J,2),1); m.Beta(~m.TermsOut)= R\(Q'*y); mout=m; else mout=m; end