简体   繁体   English

Matlab非线性方程求解器

[英]matlab nonlinear equation solver

i have a set of3 nonlinear equations and i need to solve them by using fsolve in matlab 我有一组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);

this is my function matlab file. 这是我的功能matlab文件。 I call this matlab function while using the matlab file 我在使用matlab文件时调用此matlab函数

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

But it is giving me the error Error using fsolve (line 258) FSOLVE requires all values returned by user functions to be of data type double. 但这给了我错误Error使用fsolve(第258行)FSOLVE要求用户函数返回的所有值的数据类型均为double。

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

Your function root2d returns symbols. 您的函数root2d返回符号。 Hence, you can not use fsolve for symbolic function, as algorithm behind fsolve is numerical. 因此,您不能将fsolve用于符号函数,因为fsolve背后的算法是数值算法。 solve function might help you. solve功能可能会对您有所帮助。

Also, in fsolve documentation mentioned that: 另外,在fsolve文档中提到:

for x, where F(x) is a function that returns a vector value . 对于x,其中F(x)是返回向量value的函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM