www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@xregrbf/leastsq.m

    function [mout,OK]= leastsq(m,x,y,Wc)
%LEASTSQ least squares estimate of model
%
% [mout,OK]= leastsq(m,x,y,Wc)

%  Copyright 2000-2006 The MathWorks, Inc. and Ford Global Technologies, Inc.

if nargin<4
    Wc=[];
end
   
[m,OK]= InitModel(m,x,y,Wc);
if OK
    % Calculate coefficients
    beta = calcBeta(m);
    m = update(m,beta);
    fitalg=get(m,'fitalg');
    if ischar(fitalg) && strcmp(fitalg,'leastsq')
        % if this is not being computed elsewhere....
        cost = log10GCV(m);
        try
            % only standard fit algorithms store cost in optimmgr
            % would like to deprecate this behaviour
            setFitOpt( m, 'cost', cost );
        end
    end
    mout=m;
else
    mout=m;
end