声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1512|回复: 3

请教,如何解非线性方程组

[复制链接]
发表于 2006-3-17 09:23 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
请教,如何解非线性方程组。demonewtonsys 函数哪位有,我怎么找不到
回复
分享到:

使用道具 举报

发表于 2006-3-17 16:31 | 显示全部楼层

回复:(chen42239)请教,如何解非线性方程组

fsolve
发表于 2006-3-17 16:34 | 显示全部楼层

回复:(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 = [0; 0]<BR>%<BR>% Output:  x = estimate of solution after maxit iterations</P>
<P>if nargin&lt;1,  maxit=5;          end<BR>if nargin&lt;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>
发表于 2006-3-19 12:06 | 显示全部楼层
<P>[x,yfun,key,c]=fsolve(F,xo,OPT)<BR><BR>F为要求解问题的数学描述,x0为自变量的起始搜索点,OPT为最优化工具箱的选项设定!</P>
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-9-26 05:16 , Processed in 0.053302 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表