MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [MATLAB基础] 高手帮忙说一下哈,小弟新学 (https://www.labfans.com/bbs/showthread.php?t=11896)

lzygod007 2010-07-24 17:23

高手帮忙说一下哈,小弟新学
 
我解这个方程组但是为什么会报错呢
function F=myfun(x)
F=[2*x(1)-x(2)-exp(-x(1));-x(1)+2*x(2)-exp(-x(2))];
x0=[-5;-5];
options=optimset('Display','iter');
[x,fval]=fsolve('myfun',x0,options)




??? Input argument "x" is undefined.

Error in ==> Untitled5 at 2
F=[2*x(1)-x(2)-exp(-x(1));-x(1)+2*x(2)-exp(-x(2))];

枯藤老树 2010-07-26 00:52

回复: 高手帮忙说一下哈,小弟新学
 
M文件
function F=myfun(x)
F(1)=2*x(1)-x(2)-exp(-x(1));
F(2)=-x(1)+2*x(2)-exp(-x(2));
调用函数
[x,fval]=fsolve('myfun',[-5,5]',optimset('Display','iter'))

枯藤老树 2010-07-26 00:59

回复: 高手帮忙说一下哈,小弟新学
 
你这两个方程是同一个方程啊


所有时间均为北京时间。现在的时间是 12:25

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.