亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? fsolve.m

?? 數值類綜合算法 常用數值計算工具包(龍貝格算法、改進歐拉法、龍格庫塔方法、復合辛普森)
?? M
字號:
function [x,FVAL,EXITFLAG,OUTPUT,JACOB] = fsolve(FUN,x,options,varargin)
%優化工具箱函數,可求多元非線性方程組的實根. 用法與fzero類似。
%例 先寫一個M函數rooteg4fun.m
%                  function  y=rooteg4fun(x)
%                  y(1)=4*x(1)-x(2)+exp(x(1))/10-1;
%                  y(2)=-x(1)+4*x(2)+x(1).^2/8;
%   使用
%      [x,f,h]=fsolve('rooteg4fun',[0,0]) %初值x(1)=0,x(2)=0 
%   x返回解向量,f返回誤差向量,h>0表明算法收斂
%   注意:方程變量必須拼成一個向量變量,即用x(1),x(2),...
%
%FSOLVE Solves nonlinear equations by a least squares method.
%
%   FSOLVE solves equations of the form:
%             
%   F(X)=0    where F and X may be vectors or matrices.   
%
%   X=FSOLVE(FUN,X0) starts at the matrix X0 and tries to solve the 
%   equations described in FUN. FUN is usually an M-file which returns 
%   an evaluation of the equations for a particular value of X: F=FUN(X).
%
%   X=FSOLVE(FUN,X0,OPTIONS) minimizes with the default optimization
%   parameters replaced by values in the structure OPTIONS, an argument
%   created with the OPTIMSET function.  See OPTIMSET for details.  Used
%   options are Display, TolX, TolFun, DerivativeCheck, Diagnostics, Jacobian,
%   JacobPattern, LineSearchType, LevenbergMarquardt, MaxFunEvals, MaxIter, 
%   DiffMinChange and DiffMaxChange, LargeScale, MaxPCGIter, PrecondBandWidth, 
%   TolPCG, TypicalX. Use the Jacobian option to specify that FUN may be called 
%   with two output arguments where the second, J, is the Jacobian matrix: 
%   [F,J] = feval(FUN,X). If FUN returns a vector (matrix) of m components when 
%   X has length n, then J is an m-by-n matrix where J(i,j) is the partial 
%   derivative of F(i) with respect to x(j). (Note that the Jacobian J is the 
%   transpose of the gradient of F.)
%
%   X=FSOLVE(FUN,X0,OPTIONS,P1,P2,...) passes the problem-dependent 
%   parameters P1,P2,... directly to the function FUN: FUN(X,P1,P2,...).  
%   Pass an empty matrix for OPTIONS to use the default values. 
%
%   [X,FVAL]=FSOLVE(FUN,X0,...) returns the value of the objective function
%    at X. 
%
%   [X,FVAL,EXITFLAG]=FSOLVE(FUN,X0,...) returns a string EXITFLAG that 
%   describes the exit condition of FSOLVE.  
%   If EXITFLAG is:
%      > 0 then FSOLVE converged to a solution X.
%      0   then the maximum number of function evaluations was reached.
%      < 0 then FSOLVE did not converge to a solution.
%
%   [X,FVAL,EXITFLAG,OUTPUT]=FSOLVE(FUN,X0,...) returns a structure OUTPUT
%   with the number of iterations taken in OUTPUT.iterations, the number of
%   function evaluations in OUTPUT.funcCount, the algorithm used in OUTPUT.algorithm,
%   the number of CG iterations (if used) in OUTPUT.cgiterations, and the first-order 
%   optimality (if used) in OUTPUT.firstorderopt.
%
%   [X,FVAL,EXITFLAG,OUTPUT,JACOB]=FSOLVE(FUN,X0,...) returns the 
%   Jacobian of FUN at X.  

%   Copyright (c) 1990-98 by The MathWorks, Inc.
%   $Revision: 1.26 $  $Date: 1998/10/22 19:28:31 $
%   Andy Grace 7-9-90.

%   Grandfathered FSOLVE call for Optimization Toolbox versions prior to 2.0:
%   [X,OPTIONS]=FSOLVE(FUN,X0,OPTIONS,GRADFUN,P1,P2,...)
%
% ------------Initialization----------------

defaultopt = optimset('display','final','LargeScale','on', ...
   'TolX',1e-6,'TolFun',1e-6,'DerivativeCheck','off',...
   'Jacobian','off','MaxFunEvals','100*numberOfVariables',...
   'Diagnostics','off',...
   'DiffMaxChange',1e-1,'DiffMinChange',1e-8,...
   'PrecondBandWidth',0,'TypicalX','ones(numberOfVariables,1)','MaxPCGIter','max(1,floor(numberOfVariables/2))', ...
   'TolPCG',0.1,'MaxIter',400,'JacobPattern',[], ...
   'LineSearchType','quadcubic','LevenbergMarq','off'); 
% If just 'defaults' passed in, return the default options in X
if nargin==1 & nargout <= 1 & isequal(FUN,'defaults')
   x = defaultopt;
   return
end

if nargin < 2, error('FSOLVE requires two input arguments');end
if nargin < 3, options=[]; end

% These are added so that we can have the same code as in lsqnonlin which
%  actually has upper and lower bounds.
LB = []; UB = [];

%[x,FVAL,EXITFLAG,OUTPUT,JACOB] = fsolve(FUNin,x,options,varargin)
% Note: don't send varargin in as a comma separated list!!
numargin = nargin; numargout = nargout;
[calltype, GRADFUN, varargin] = parse_call(FUN,options,numargin,numargout,varargin);

if isequal(calltype,'new')  % fsolve version 2.*
   
   xstart=x(:);
   numberOfVariables=length(xstart);
   
   large = 'large-scale';
   medium = 'medium-scale';
   
   l = []; u = [];
   
   options = optimset(defaultopt,options);
   switch optimget(options,'display')
   case {'off','none'}
      verbosity = 0;
   case 'iter'
      verbosity = 2;
   case 'final'
      verbosity = 1;
   case 'testing'
      verbosity = Inf;
   otherwise
      verbosity = 1;
   end
   diagnostics = isequal(optimget(options,'diagnostics','off'),'on');
   
   gradflag =  strcmp(optimget(options,'Jacobian'),'on');
   line_search = strcmp(optimget(options,'largescale','off'),'off'); % 0 means trust-region, 1 means line-search
   
   % Convert to inline function as needed
   if ~isempty(FUN)  % will detect empty string, empty matrix, empty cell array
      [funfcn, msg] = fprefcnchk(FUN,'fsolve',length(varargin),gradflag);
   else
      errmsg = sprintf('%s\n%s', ...
         'FUN must be a function name, valid string expression, or inline object;', ...
         ' or, FUN may be a cell array that contains these type of objects.');
      error(errmsg)
   end
   
   x(:) = xstart;
   switch funfcn{1}
   case 'fun'
      fuser = feval(funfcn{3},x,varargin{:});
      f = fuser(:);
      nfun=length(f);
      JAC = zeros(nfun,numberOfVariables);
   case 'fungrad'
      [fuser,JAC] = feval(funfcn{3},x,varargin{:});
      f = fuser(:);
      nfun=length(f);
   case 'fun_then_grad'
      fuser = feval(funfcn{3},x,varargin{:}); 
      f = fuser(:);
      JAC = feval(funfcn{4},x,varargin{:});
      nfun=length(f);
      
   otherwise
      error('Undefined calltype in FSOLVE');
   end
   
   % check size of JAC
   [Jrows, Jcols]=size(JAC);
   if Jrows~=nfun | Jcols ~=numberOfVariables
      errstr = sprintf('%s\n%s%d%s%d\n',...
         'User-defined Jacobian is not the correct size:',...
         '    the Jacobian matrix should be ',nfun,'-by-',numberOfVariables);
      error(errstr);
   end
   
   YDATA = []; caller = 'fsolve';
   
   % trustregion and enough equations (as many as variables) 
   if ~line_search & nfun >= numberOfVariables 
      OUTPUT.algorithm = large;
      
      % trust region and not enough equations -- switch to line_search
   elseif ~line_search & nfun < numberOfVariables 
      warnstr = sprintf('%s\n%s\n', ...
         'Large-scale method requires at least as many equations as variables; ',...
         '   switching to line-search method instead.');
      warning(warnstr);
      OUTPUT.algorithm = medium;
      
      % line search and no bounds  
   elseif line_search & isempty(l) & isempty(u)
      OUTPUT.algorithm = medium;
      
      % line search and  bounds  and enough equations, switch to trust region 
   elseif line_search & (~isempty(LB) | ~isempty(UB))  & nfun >= numberOfVariables
      warnstr = sprintf('%s\n%s\n', ...
         'Line-search method does not handle bound constraints; ',...
         '   switching to trust-region method instead.');
      warning(warnstr);
      OUTPUT.algorithm = large;
      
      % can't handle this one:   
   elseif line_search & (~isempty(LB) | ~isempty(UB))  & nfun < numberOfVariables
      errstr = sprintf('%s\n%s\n%s\n', ...
         'Line-search method does not handle bound constraints ',...
         '   and trust-region method requires at least as many equations as variables; ',...
         '   aborting.');
      error(errstr);
      
   end
   
   if diagnostics > 0
      % Do diagnostics on information so far
      constflag = 0; gradconstflag = 0; non_eq=0;non_ineq=0;lin_eq=0;lin_ineq=0;
      confcn{1}=[];c=[];ceq=[];cGRAD=[];ceqGRAD=[];
      hessflag = 0; HESS=[];
      msg = diagnose('fsolve',OUTPUT,gradflag,hessflag,constflag,gradconstflag,...
         line_search,options,xstart,non_eq,...
         non_ineq,lin_eq,lin_ineq,LB,UB,funfcn,confcn,f,JAC,HESS,c,ceq,cGRAD,ceqGRAD);
      
   end
   
   % Execute algorithm
   if isequal(OUTPUT.algorithm, large)
      if ~gradflag
         Jstr = optimget(options,'JacobPattern',[]);
         if isempty(Jstr)  
            % Put this code separate as it might generate OUT OF MEMORY error
            Jstr = sparse(ones(Jrows,Jcols));
         end
      else
         Jstr = [];
      end
      l = []; u = []; computeLambda = 0;
      [x,FVAL,LAMBDA,JACOB,EXITFLAG,OUTPUT]=...
         snls(funfcn,x,l,u,verbosity,options,f,JAC,YDATA,caller,Jstr,computeLambda,varargin{:});
   else 
      [x,FVAL,JACOB,EXITFLAG,OUTPUT] = ...
         nlsq(funfcn,x,verbosity,options,f,JAC,YDATA,caller,varargin{:});
      
   end
   
   Resnorm = FVAL'*FVAL;  % assumes FVAL still a vector
   if Resnorm > 10*optimget(options,'TolFun',1e-4) & verbosity>0
      if verbosity > 0
         disp('Optimizer is stuck at a minimum that is not a root')
         disp('Try again with a new starting guess')
      end
      EXITFLAG = -1;
   end
   
   % Reset FVAL to shape of the user-function output, fuser
   FVAL = reshape(FVAL,size(fuser));
   
   % end FSOLVE 2.*
else % version 1.5 FSOLVE
   
   if length(options)<5; 
      options(5)=0; 
   end
   % Switch methods making Gauss Newton the default method.
   if options(5)==0; options(5)=1; else options(5)=0; end
   
   % Convert to inline function as needed.
   if ~isempty(FUN)
      [funfcn, msg] = fcnchk(FUN,length(varargin));
      if ~isempty(msg)
         error(msg);
      end
   else
      error('FUN must be a function name or valid expression.')
   end
   
   if ~isempty(GRADFUN)
      [gradfcn, msg] = fcnchk(GRADFUN,length(varargin));
      if ~isempty(msg)
         error(msg);
      end
   else
      gradfcn = [];
   end
   
   [x,options] = nlsqold(funfcn,x,options,gradfcn,varargin{:});
   
   if options(8)>10*options(3) & options(1)>0
      disp('Optimizer is stuck at a minimum that is not a root')
      disp('Try again with a new starting guess')
   end
   
   % Set the second output argument FVAL to be options as in old calling syntax
   FVAL = options;
   
   % end fsolve version 1.5.*
   
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [calltype, GRADFUN, otherargs] = parse_call(FUN,options,numargin,numargout,otherargs)
% PARSE_CALL Determine which calling syntax is being used: the FSOLVE prior to 2.0, or
%    in version 2.0 or later of the Toolbox.
%    old call: [X,OPTIONS]=FSOLVE(FUN,X0,OPTIONS,GRADFUN,varargin)
%    new call: [X,FVAL,EXITFLAG,OUTPUT,JACOB]=FSOLVE(FUN,X0,OPTIONS,varargin)

if numargout > 2               % [X,FVAL,EXITFLAG,...]=FSOLVE (...)
   calltype = 'new';
   GRADFUN = []; 
elseif isa(FUN,'cell')         % FUN == {...}
   calltype = 'new';
   GRADFUN = [];
elseif ~isempty(options) & isa(options,'double')   % OPTIONS == scalar or and array
   calltype = 'old';
   if length(otherargs) > 0
      GRADFUN = otherargs{1};
      otherargs = otherargs(2:end);
   else
      GRADFUN = [];
   end
elseif isa(options,'struct')   % OPTIONS has fields
   calltype = 'new';
   GRADFUN = [];
else                           % Ambiguous
   warnstr = sprintf('%s\n%s\n%s\n',...
      'Cannot determine from calling sequence whether to use new (2.0 or later) FSOLVE ', ...
      'function or grandfathered FSOLVE function.  Assuming new syntax; if call was grandfathered', ...
      'FSOLVE syntax, this may give unexpected results.');
   warning(warnstr)
   calltype = 'new';
   GRADFUN = [];
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [allfcns,msg] = fprefcnchk(funstr,caller,lenVarIn,gradflag)
%PREFCNCHK Pre- and post-process function expression for FUNCHK.
%   [ALLFCNS,MSG] = PREFUNCHK(FUNSTR,CALLER,lenVarIn,GRADFLAG) takes
%   the (nonempty) expression FUNSTR from CALLER with LenVarIn extra arguments,
%   parses it according to what CALLER is, then returns a string or inline
%   object in ALLFCNS.  If an error occurs, this message is put in MSG.
%
%   ALLFCNS is a cell array: 
%    ALLFCNS{1} contains a flag 
%    that says if the objective and gradients are together in one function 
%    (calltype=='fungrad') or in two functions (calltype='fun_then_grad')
%    or there is no gradient (calltype=='fun'), etc.
%    ALLFCNS{2} contains the string CALLER.
%    ALLFCNS{3}  contains the objective function
%    ALLFCNS{4}  contains the gradient function (transpose of Jacobian).
%  
%    NOTE: we assume FUNSTR is nonempty.
% Initialize
msg='';
allfcns = {};
funfcn = [];
gradfcn = [];

if gradflag
   calltype = 'fungrad';
else
   calltype = 'fun';
end

% {fun}
if isa(funstr, 'cell') & length(funstr)==1
   % take the cellarray apart: we know it is nonempty
   if gradflag
      calltype = 'fungrad';0
   end
   [funfcn, msg] = fcnchk(funstr{1},lenVarIn);
   if ~isempty(msg)
      error(msg);
   end
   
   % {fun,[]}      
elseif isa(funstr, 'cell') & length(funstr)==2 & isempty(funstr{2})
   if gradflag
      calltype = 'fungrad';
   end
   [funfcn, msg] = fcnchk(funstr{1},lenVarIn);
   if ~isempty(msg)
      error(msg);
   end  
   
   % {fun, grad}   
elseif isa(funstr, 'cell') & length(funstr)==2 % and ~isempty(funstr{2})
   
   [funfcn, msg] = fcnchk(funstr{1},lenVarIn);
   if ~isempty(msg)
      error(msg);
   end  
   [gradfcn, msg] = fcnchk(funstr{2},lenVarIn);
   if ~isempty(msg)
      error(msg);
   end
   calltype = 'fun_then_grad';
   if ~gradflag
      warnstr = ...
         sprintf('%s\n%s\n%s\n','Jacobian function provided but OPTIONS.Jacobian=''off'';', ...
         '  ignoring Jacobian function and using finite-differencing.', ...
         '  Rerun with OPTIONS.Jacobian=''on'' to use Jacobian function.');
      warning(warnstr);
      calltype = 'fun';
   end   
   
elseif ~isa(funstr, 'cell')  %Not a cell; is a string expression, function name string or inline object
   [funfcn, msg] = fcnchk(funstr,lenVarIn);
   if ~isempty(msg)
      error(msg);
   end   
   if gradflag % gradient and function in one function/M-file
      gradfcn = funfcn; % Do this so graderr will print the correct name
   end  
else
   errmsg = sprintf('%s\n%s', ...
      'FUN must be a function name, valid string expression, or inline object;', ...
      ' or, FUN may be a cell array that contains these type of objects.');
   error(errmsg)
end

allfcns{1} = calltype;
allfcns{2} = caller;
allfcns{3} = funfcn;
allfcns{4} = gradfcn;
allfcns{5}=[];

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人黄色在线看| 久久婷婷一区二区三区| 日韩女优电影在线观看| 国产精品人妖ts系列视频| 亚洲mv在线观看| 99精品国产91久久久久久| 精品国产电影一区二区| 亚洲午夜三级在线| 99久久国产综合精品色伊| 欧美大片一区二区三区| 一区二区三区欧美视频| 成人av先锋影音| 国产欧美日韩卡一| 国产一区二区女| 欧美成人乱码一区二区三区| 一区二区三区电影在线播| 国产高清精品在线| 精品国产欧美一区二区| 午夜不卡av在线| 91国偷自产一区二区三区观看 | 精品久久人人做人人爰| 亚洲一区二区欧美日韩| 一本一本久久a久久精品综合麻豆| 久久久夜色精品亚洲| 美女一区二区视频| 日韩一区二区三区视频在线观看| 亚洲图片欧美一区| 欧美日本在线播放| 亚洲最大色网站| 欧美日韩一区二区在线观看视频| 亚洲男人的天堂在线观看| 色欧美日韩亚洲| 一区二区免费在线播放| 欧美三级在线视频| 香蕉乱码成人久久天堂爱免费| 欧洲av在线精品| 国产91综合网| 久久久久久99久久久精品网站| 国内精品国产成人国产三级粉色| 欧美日韩aaaaaa| 美女网站色91| 久久精品男人天堂av| 成人丝袜视频网| 亚洲特黄一级片| 欧美吞精做爰啪啪高潮| 日韩国产一区二| 久久综合九色综合欧美就去吻| 国产成人啪免费观看软件| 中文字幕精品三区| 91蜜桃在线观看| 香蕉久久一区二区不卡无毒影院| 日韩一区二区三区视频在线 | 欧美系列日韩一区| 日韩av中文字幕一区二区三区| 91精品国产综合久久精品麻豆| 秋霞国产午夜精品免费视频| 精品久久久久久久久久久院品网| 国产盗摄视频一区二区三区| 国产精品入口麻豆九色| 欧美在线不卡一区| 奇米色一区二区| 中文字幕巨乱亚洲| 欧美日韩午夜精品| 国产一区高清在线| 亚洲综合在线电影| 久久在线观看免费| 欧美色图在线观看| 国产精品原创巨作av| 亚洲素人一区二区| 欧美mv日韩mv亚洲| 色哟哟在线观看一区二区三区| 午夜精品久久一牛影视| 久久精品欧美一区二区三区不卡| 日本韩国欧美一区二区三区| 精品一区二区免费看| 一区二区三区欧美视频| 精品国产污污免费网站入口 | 老司机精品视频线观看86| 成人免费一区二区三区在线观看 | 日韩欧美国产综合一区 | 91福利在线导航| 国产一区高清在线| 亚洲va天堂va国产va久| 国产亚洲一区二区三区四区| 欧美视频一区二区三区| 国产91丝袜在线观看| 美女视频黄久久| 亚洲午夜私人影院| 国产精品乱子久久久久| 欧美岛国在线观看| 欧美日韩视频在线一区二区| 成人免费不卡视频| 国产精品一区2区| 久久精品国产色蜜蜜麻豆| 亚洲成人免费av| 亚洲三级视频在线观看| 国产色产综合色产在线视频| 欧美日韩国产首页在线观看| 不卡的电视剧免费网站有什么| 激情综合网av| 青青草97国产精品免费观看无弹窗版| 亚洲日本成人在线观看| 亚洲国产精品成人综合| 26uuu精品一区二区| 欧美一区永久视频免费观看| 欧美在线观看一区| 91丨九色porny丨蝌蚪| 成人看片黄a免费看在线| 国产精品一区二区久久不卡| 韩国毛片一区二区三区| 精品一区在线看| 久久se精品一区二区| 日本亚洲欧美天堂免费| 日韩中文字幕区一区有砖一区| 亚洲在线中文字幕| 午夜日韩在线观看| 日本系列欧美系列| 免费在线看成人av| 久久精品国产**网站演员| 美女精品自拍一二三四| 精品一区二区三区在线视频| 久久精品av麻豆的观看方式| 国内精品自线一区二区三区视频| 久久99精品国产| 国产一区二区三区美女| 国产91露脸合集magnet| 日韩欧美久久久| 国产人成一区二区三区影院| 国产亚洲1区2区3区| 国产精品网站一区| 综合电影一区二区三区| 亚洲国产成人av网| 麻豆视频一区二区| 国产激情视频一区二区三区欧美 | 亚洲图片欧美色图| 日韩制服丝袜av| 国产在线不卡视频| 91在线云播放| 欧美日韩国产三级| 精品国产免费一区二区三区四区 | 蜜臀精品一区二区三区在线观看| 美国毛片一区二区三区| 国产99久久久国产精品潘金网站| 99精品久久99久久久久| 欧美日韩一区在线| 精品国内片67194| 国产精品盗摄一区二区三区| 亚洲福利一二三区| 国产乱码一区二区三区| 在线视频一区二区三| 欧美成人三级电影在线| 中文字幕佐山爱一区二区免费| 天堂蜜桃91精品| 国产成人精品综合在线观看| 在线免费一区三区| 国产日本亚洲高清| 视频一区欧美精品| 99久久精品一区| 欧美成人激情免费网| 亚洲人午夜精品天堂一二香蕉| 日本午夜精品一区二区三区电影 | 日本一区二区视频在线观看| 一区二区欧美精品| 懂色av一区二区三区蜜臀| 欧美老年两性高潮| 国产精品国产三级国产有无不卡| 亚洲第一福利一区| 99久久伊人精品| 久久一区二区三区四区| 午夜影院久久久| 色综合夜色一区| 国产婷婷一区二区| 久久99精品一区二区三区三区| 99re这里只有精品首页| 久久一二三国产| 免费的成人av| 欧美性色黄大片手机版| 国产精品久久久久久久第一福利 | 国产精品视频你懂的| 久久精品国产一区二区三区免费看| 一本到高清视频免费精品| 欧美国产日韩亚洲一区| 国产一区二区不卡在线| 日韩午夜三级在线| 亚洲第一在线综合网站| 91久久免费观看| 亚洲精品一二三四区| bt欧美亚洲午夜电影天堂| 日本一区二区免费在线观看视频| 99久久免费国产| 欧美激情中文字幕| 国产激情精品久久久第一区二区| 日韩女优毛片在线| 美女视频一区二区| 日韩亚洲欧美中文三级| 日本亚洲最大的色成网站www| 欧美日韩日日骚| 亚洲丰满少妇videoshd| 欧美亚洲综合在线| 图片区小说区国产精品视频|