注册 登录
编程论坛 Matlab

[求助]用fsolve解方程

ydanc 发布于 2006-12-14 13:58, 2320 次点击

我想求解以下方程的解:
2/(7.8^2+2.9^2/(1+(40/(x-630))^2))^2+2/(7.8^2+2.9^2/(1+(40/(x+630))^2))^2+2/(7.8^2+2.9^2/(1+(40/x)^2))^2-2/(7.8^2+2.9^2*630^2/(630^2+40^2))^2-1/(7.8^4)=0
我编的M文件如下:
function y=feifun(x)
y=2/(7.8^2+2.9^2/(1+(40/(x-630))^2))^2+2/(7.8^2+2.9^2/(1+(40/(x+630))^2))^2+2/(7.8^2+2.9^2/(1+(40/x)^2))^2-2/(7.8^2+2.9^2*630^2/(630^2+40^2))^2-1/(7.8^4);
%x0=0.5;
%k=7.8;
%m=2.9;
%z=40
%h=630;
%调用fsolve求解带参数方程
x0=0;
x=fsolve(@(x)feifun(x),x0);
运行后的错误如下:
??? Input argument "x" is undefined.

Error in ==> fangch at 2
y=2/(7.8^2+2.9^2/(1+(40/(x-630))^2))^2+2/(7.8^2+2.9^2/(1+(40/(x+630))^2))^2+2/(7.8^2+2.9^2/(1+(40/x)^2))^2-2/(7.8^2+2.9^2*630^2/(630^2+40^2))^2-1/(7.8^4);
请问这是什么意思呢?谢谢:)

5 回复
#2
abingchem2006-12-14 14:13
已经成函数了,这样写试试:
x=fsolve(@feifun,x0)
#3
ydanc2006-12-14 16:10

还是一样的错误,怎么办呢?头疼~

#4
abingchem2006-12-14 20:20
你用的什么版本啊?
用6.5,至少这样是可以的
x=fsolve(@feifun,x0,optimset('fsolve'));
#5
ydanc2006-12-14 21:42

我用的7.0的,不知道为什么不行,不过后来我用
x=solve('2/(2.9^2+7.8^2/(1+(40/(x-0.063))^2))^2+2/(2.9^2+7.8^2/(1+(40/(x+0.063))^2))^2+2/(2.9^2+7.8^2/(1+(40/x)^2))^2-2/(2.9^2+7.8^2*0.063^2/(0.063^2+40^2))^2-1/(2.9^4)');
还好解出来了。

#6
ydanc2006-12-14 21:48
另外我还想请教一个问题:我想划一个曲线,满足以下的方程(其实跟前面的一样的,只不过前面的参数给定了):
2/(k^2+m^2/(1+(40/(y-x))^2))^2+2/(k^2+m^2/(1+(40/(y+x))^2))^2+2/(k^2+m^2/(1+(40/y)^2))^2-2/(k^2+m^2*x^2/(x^2+40^2))^2-1/(k^4)=0
我画出y随着另外两个或者三个参数变化的曲线图,应该用什么函数呢?本来就不怎么会matlab,在书本上找好迷茫啊。。。。
希望多多指点,谢谢啦:)
1