matlab用fsolve求解非线性方程组,无法求解……方程组如下function eq=gf(x)%给出已知的近似解x=[195.3 0.001 389.3 249.4]Ap=556;As=942;fsk=337.35;e0=0.002;z=421.4;hp=429;hs=551;Ep=195000;Es=200000;eq(1)=Ap*x(4)+As*x(3)-(Ap+As)*fs
来源:学生作业帮助网 编辑:六六作业网 时间:2024/09/08 00:21:12
matlab用fsolve求解非线性方程组,无法求解……方程组如下function eq=gf(x)%给出已知的近似解x=[195.3 0.001 389.3 249.4]Ap=556;As=942;fsk=337.35;e0=0.002;z=421.4;hp=429;hs=551;Ep=195000;Es=200000;eq(1)=Ap*x(4)+As*x(3)-(Ap+As)*fs
matlab用fsolve求解非线性方程组,无法求解……
方程组如下
function eq=gf(x)
%给出已知的近似解x=[195.3 0.001 389.3 249.4]
Ap=556;
As=942;
fsk=337.35;
e0=0.002;
z=421.4;
hp=429;
hs=551;
Ep=195000;
Es=200000;
eq(1)=Ap*x(4)+As*x(3)-(Ap+As)*fsk;
eq(2)=(4*e0-x(2))/(12*e0-4*x(2))*x(1)+z-(hp+hs)/2;
eq(3)=x(4)*x(1)-Ep*(hp-x(1))*x(2);
eq(4)=x(3)*x(1)-Es*(hs-x(1))*x(2);
end
运行[xybest,fval]=fsolve('gf',[195.3,0.001,389.3,249.4])后出现如下错误:
>> [xybest,fval]=fsolve('gf',[195.3,0.001,389.3,249.4])
Error using ==> gf.gf at 66
X must be between 0 and 2^m-1
Error in ==> fsolve at 253
fuser = feval(funfcn{3},x,varargin{:});
Caused by:
Failure in initial user-supplied objective function evaluation.FSOLVE
cannot continue.
请问是什么原因呢?给出的近似解已经手算验证,没有太大问题,
matlab用fsolve求解非线性方程组,无法求解……方程组如下function eq=gf(x)%给出已知的近似解x=[195.3 0.001 389.3 249.4]Ap=556;As=942;fsk=337.35;e0=0.002;z=421.4;hp=429;hs=551;Ep=195000;Es=200000;eq(1)=Ap*x(4)+As*x(3)-(Ap+As)*fs
给你看了,gf是matlab已有的函数名了,可输入help gf 查看,因此你定义了一个和gf函数重名的自己的函数,把gf随便改成另一个名字,如myfun,fsolve里也要改,不要跟matlab内置的函数重名,否则系统不识别哪一个是你想要求解的,这就叫机器与人脑的本质区别,调用结果如下:
[xybest,fval]=fsolve('myfun',[195.3,0.001,389.3,249.4])
Equation solved, fsolve stalled.
fsolve stopped because the relative size of the current step is less than the
default value of the step size tolerance squared and the vector of function values
is near zero as measured by the default value of the function tolerance.
xybest =
195.2302 0.0011 389.2688 249.3868
fval =
1.0e-011 *
0
0
-0.7276
0
注意:切记不要再犯这种错误,大多数人也查不出来的错误,加油.