matlab非线性方程求解器

matlab nonlinear equation solver

我有一组 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 要求用户函数返回的所有值都是双精度数据类型。

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

你的函数 root2d returns 个符号。因此,您不能将 fsolve 用于符号函数,因为 fsolve 背后的算法是数值的。 solve 函数可能对您有帮助。

此外,在 fsolve 文档中提到:

for x, where F(x) is a function that returns a vector value.