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

    function [U,OK]= leastsq(U,x,y,Wc)
%LEASTSQ
%
% [U,OK]= leastsq(U,x,y,varargin);

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

if nargin < 4
    Wc = [];
end
x0= U.parameters;
OK= false;
if length(x0)<=size(y,1)
    try
        om = optimargs(U);
        % run optimisation
        
        [U,~,OK,xf]= run(om,U,x0,x,y,Wc);
        if OK
            U.parameters= xf;
            [U,OK]= InitModel(U,x,y,Wc,true);
        end
    catch ME
        ReportError(U,ME)
    end
end