Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
![]() |
#1 |
初级会员
注册日期: 2010-11-08
年龄: 39
帖子: 1
声望力: 0 ![]() |
![]()
当用fsolve这个函数解一个非线性方程时,出现了设定什么样的初始值就会得到什么样的解的情况,但这个解并不是我要解的方程组的解。 这种问题该怎么解决:
程序提示警告如下: Warning: Default trust-region dogleg method of FSOLVE cannot handle non-square systems; using Gauss-Newton method instead. > In fsolve at 248 In bxx at 16 Optimization terminated: directional derivative along search direction less than TolFun and infinity-norm of gradient less than 10*(TolFun+TolX). 程序如下: 函数文件: function F=myfunx(x) global fr22 fr33 fr44 PP; F=[x(1).*conj(x(1)).*(cos(x(3))).^4+x(2).*conj(x(2)).*(sin(x(3))).^4-2.*x(1).*x(2).*(sin(x(3))).^2.*(cos(x(3))).^2.*cos(pi-PP)-fr22.*conj(fr22); x(1).*conj(x(1)).*(cos(x(3)+pi/18)).^4+x(2)*conj(x(2)).*(sin(x(3)+pi/18)).^4-2.*x(1).*x(2).*(sin(x(3)+pi/18)).^2.*(cos(x(3)+pi/18)).^2*cos(pi-PP)-fr33.*conj(fr33); x(1)*conj(x(1)).*(cos(x(3)+pi/9)).^4+x(2).*conj(x(2)).*(sin(x(3)+pi/9)).^4-2.*x(1).*x(2).*(sin(x(3)+pi/9)).^2.*(cos(x(3)+pi/9)).^2.*cos(pi-PP)-fr44.*conj(fr44)]; 在同一工作目录下,在MatLab命令窗口运行下列指令 clc clear all fr22=-0.000000153833007 + 0.000000370929161i; fr33=-0.00000058448337 + 0.000000878668962i; fr44=-0.000000868865919 + 0.000001438884514i; PP=5.38205; %%解方程 x0=[7e-9;-2.6316396111025e-10;pi/3]; %给变量初始值 Result=fsolve(@myfunx,x0) % 求解方程,options默认,等价形式还可以写成 x=fsolve('myfun1',x0) 得到的结果: Warning: Default trust-region dogleg method of FSOLVE cannot handle non-square systems; using Gauss-Newton method instead. > In fsolve at 248 Optimization terminated: directional derivative along search direction less than TolFun and infinity-norm of gradient less than 10*(TolFun+TolX). Result = 0.0000 -0.0000 1.0472 诚请高手帮忙解答~~ 不胜感激!!!! |
![]() |
![]() |
![]() |
#2 |
初级会员
注册日期: 2010-09-13
帖子: 3
声望力: 0 ![]() |
![]()
不好搞,初始点的设置是这个函数的关键,说不清的。
|
![]() |
![]() |