新手求助 关于用Fsolve解非线性方程组。

首先这是我的m函数文件
function q=myfun(x)
q=[x(1)+x(2)-98;
x(1)^(1/3)+x(2)^(1/3)-2]
然后在调用
x=fsolve('myfun',[2,-1],optimset('Display','off'))
得到结果
x =
98.4271 - 0.5792i -0.0914 + 0.0000i 前面还有很多无用的东西
这结果是不对的 结果是 125 - 27 我想知道错在哪里 跪求各位大神解答! 还有就是这个方程的同构是能求出来的
function q=myfun(x)
q=[x(1)+x(2)-2;
x(1)^3+x(2)^3-98]
x=fsolve('myfun',[2,-1],optimset('Display','off'))
结果 x =
5.0000 -3.0000
这有是问什么? 跪求了 这是老师给我的作业

 Réponse acceptée

kowelin
kowelin le 20 Nov 2022

0 votes

是的,没注意到这个情况,其主要原因是因为matlab在计算(-27)^(1/3)的时候,结果不是-3,而是:
ans =
1.5000 + 2.5981i
所以在描述1/3次幂的时候应该使用nthroot开立方根才对:
q=@(x)[x(1)+x(2)-98;
nthroot(x(1),3)+nthroot(x(2),3)-2];
[x,fval]=fsolve(q,[111,11])

Plus de réponses (0)

Catégories

En savoir plus sur Simulink dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!