请教,如何解非线性方程组
请教,如何解非线性方程组。demonewtonsys 函数哪位有,我怎么找不到回复:(chen42239)请教,如何解非线性方程组
fsolve回复:(chen42239)请教,如何解非线性方程组
<P>function x = demoNewtonSys(maxit,x0)<BR>% demoNewtonSys Solve a 2-by-2 nonlinear system by Newton's method<BR>% The system is<BR>% 1.4*x1 - x2 = 0.6<BR>% x1^2 - 1.6*x1 - x2 = 4.6<BR>%<BR>% Synopsis:x = demoNewtonSys<BR>% x = demoNewtonSys(maxit)<BR>% x = demoNewtonSys(maxit,x0)<BR>%<BR>% Input: maxit = (optional) max number of iterations.Default: maxit = 5<BR>% x0 = (optional) initial guess at solution.Default:x0 = <BR>%<BR>% Output:x = estimate of solution after maxit iterations</P><P>if nargin<1,maxit=5; end<BR>if nargin<2,x0 = zeros(2,1);end</P>
<P>% --- Coefficients for the case of two distinct solutions<BR>alpha =1.4;bbeta = -0.6;sigma = -1.6;tau = -4.6;</P>
<P>x = x0; f = zeros(size(x));</P>
<P>fprintf('\n k x(1) x(2) norm(f) norm(dx)\n');<BR>for k = 1:maxit<BR> f(1) = alpha*x(1) - x(2) + bbeta;<BR> f(2) = x(1)^2 + sigma*x(1) - x(2) + tau;<BR> J = [ alpha-1; (2*x(1)+sigma)-1 ];<BR> dx = -J\f;<BR> fprintf('%4d %9.5f %9.5f %10.2e %10.2e\n',...<BR> k-1,x(1),x(2),norm(f),norm(dx));<BR> x = x + dx;<BR>end<BR>fprintf('%4d %9.5f %9.5f\n',k,x(1),x(2));<BR><BR><BR>你要的不知道是不是这个</P> <P>=fsolve(F,xo,OPT)<BR><BR>F为要求解问题的数学描述,x0为自变量的起始搜索点,OPT为最优化工具箱的选项设定!</P>
页:
[1]