www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@xregusermod/optimargs.m
function [om,optparams]= optimargs(U,varargin) %OPTIMARGS input arguments for least squares optimisation % % [om,optparams]= optimargs(U,varargin); % Copyright 2000-2007 The MathWorks, Inc. and Ford Global Technologies, Inc. [LB,UB,A,c,nlcon,optparams]=constraints(U,varargin{:}); LB = LB(:); UB = UB(:); if isNumJac(U) % don't use analytic jacobians for transient % no analytic jacobian Jcalc='off'; else Jcalc='on'; end if ~isempty(A) || nlcon>0 fopts= optimset(optimset('fmincon'),... 'largescale','off',... 'Algorithm','active-set',... 'display','off','GradObj',Jcalc); else fopts= optimset(optimset('lsqnonlin'),'display','off','Jacobian',Jcalc); end om= foptions(U,fopts); %#ok if nlcon constrArgs= {LB,UB,A,c,@nlconstraints}; else constrArgs= {LB,UB,A,c,''}; end if isa(om,'xregoptmgr') % foptions defines an xregoptmgr add a constraints om=setConstraints(om,constrArgs{:}); else fopts= om; % make an optmgr object om= xregoptmgr(@nlleastsq,U,@lsqopt); om=setConstraints(om,constrArgs{:}); props=fieldnames(get(om)); for i=1:length(props)-2 if ~isempty(fopts.(props{i})) try set(om,props{i},fopts.(props{i})) end end end end