首页 文章

matlab非线性方程求解器

提问于
浏览
0

我有一组3个非线性方程组,我需要在matlab中使用fsolve来解决它们

function F = root2d(y)
 syms b1 b2 b3 w21 w31 theta1 theta2 theta3 a1 a2 a3;
 F(1) = (1+exp(-b1*(w21*y(2)+w31*y(3)-theta1)))^(-1) - a1*y(1);
 F(2) = (1/(1+exp(-b2*(y(1)-theta2))))-a2*y(2);
 F(3)=   (1/(1+exp(-b3*(y(1)-theta3))))-a3*y(3);

这是我的函数matlab文件 . 我在使用matlab文件时调用了这个matlab函数

fun = @root2d;
      x0 = [0,0,0];
      x = fsolve(fun,x0)

但它给了我错误使用fsolve错误(第258行)FSOLVE要求用户函数返回的所有值都是数据类型double .

Untitled5中的错误(第3行)x = fsolve(fun,x0)有人可以帮忙吗?

1 回答

  • 1

    您的函数 root2d 返回符号 . 因此,您不能将 fsolve 用于符号函数,因为 fsolve 后面的算法是数字 . solve 功能可能对您有所帮助 .

    另外,在 fsolve 文档中提到:

    for x,其中F(x)是返回矢量值的函数 .

相关问题