简体   繁体   中英

matlab nonlinear equation solver

i have a set of3 nonlinear equations and i need to solve them by using fsolve in matlab

  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. I call this matlab function while using the matlab file

      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 in Untitled5 (line 3) x = fsolve(fun,x0) can somebody help ?

Your function root2d returns symbols. Hence, you can not use fsolve for symbolic function, as algorithm behind fsolve is numerical. solve function might help you.

Also, in fsolve documentation mentioned that:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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