www.gusucode.com > mbc 工具箱 matlab 源码程序 > mbc/@mbcmodel/@model/Fit.m

    function [statistics,objOut] = Fit(obj, X, Y)
%FIT    Fit model to data.
%
%   [STATS,MODEL] = FIT( MODEL )
%   [STATS,MODEL] = FIT( MODEL, X, Y )

%   Copyright 2004-2011 The MathWorks, Inc.

% make a copy of the object
objOut = copy(obj);
if nargin == 3
    objOut.pSetData(X, Y);

    % Force a complete refit (i.e. revert to a full fit rather than leastsq)
    m = reset(objOut.Object);
else
    [X, Y] = pGetData(objOut);

    m = objOut.Object;
end

lam= get(m,'boxcox');
if lam~=1
    % update boxcox transformation for possible change in data
    set(m,'boxcox',{lam,double(Y)});
end
objOut.IsBeingEdited = false;
[objOut.Object, objOut.ModelStatus, statistics] = fitmodel(m, X, Y);
if nargout<2
    warning(message('mbc:mbcmodel:Obsolete7a7'))
    % make this work by reference
    obj.IsBeingEdited = false;
    obj.Object = objOut.Object;
    obj.ModelStatus = objOut.ModelStatus;
    obj.pSetData(X, Y);
end