www.gusucode.com > mbc 工具箱 matlab 源码程序 > mbc/@mbcmodel/@localmodel/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 2006-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
    m = objOut.Object;
end
[X, Y] = pGetData(objOut);
% make sweepset


objOut.IsBeingEdited = false;
[objOut.Object,objOut.ModelStatus,statistics] = fit(m,X,Y);
if nargout<2
    warning(message('mbc:mbcmodel:Obsolete7a4'))
    % make this work by reference
    obj.IsBeingEdited = false;
    obj.Object = objOut.Object;
    obj.ModelStatus = objOut.ModelStatus;
    obj.pSetData(X, Y);
end