I am trying to use the fsolve function to solve a non linear equation .In the function i created all the constants are matrices.and i expect a vector of the unknown.I keep getting error of not enough input argument.Iwould much appreciate your help.

2 次查看(过去 30 天)
function F = TRIAL3(x, V1,W1 ,W, w, z, Z1,Z, p, p1, q1, q, c1, V, v, j)
a=x(1); r = x(2); s = x(3); b=x(4); g = x(5); d = x(6); h = x(7);
F = [(V1*((c1- W*r - Z*s)+(p*b- W*r*b^2 -Z*s*b.^2 - j*d*b) +(q*g- W*r*g^2- Z*s*g.^2 - j*h*g)))-1*a- a*b^2 - a*g.^2;
(W1*((c1- V*a - Z*s)+(p*b- V*a*b^2 -Z*s*b.^2 - j*d*b) +(q*g- V*a*g^2 - Z*s*g.^2 - j*h*g)))-1*r- r*b^2 - r*g.^2;
(Z1*((c1- V*a- W*r)+ (p*b- V*r*b^2 -W*r*b.^2 - j*d*b) +(q*g- V*a*g^2 - W*r*g.^2 - j*h*g)))-1*s- s*b^2 - s*g.^2;
(inv(a'*v*V*a + a'*v*W*r +a'*v*Z*s + r'*w*V*a + r'*w*W*r+ r'*w*Z*s + s'*z*V*a+ s'*z*W*r +s'*z*Z*s)*(p1*V*a+ p1*W*r + p1*Z*s -a'*v*j*d - r'*W'*j*d +s'*Z'*j*d))-b;
(inv(a'*v*V*a + a'*v*W*r +a'*v*Z*s + r'*w*V*a + r'*w*W*r+ r'*w*Z*s + s'*z*V*a+ s'*z*W*r +s'*z*Z*s)*(q1*V*a+ q1*W*r + q1*Z*s -a'*v*j*h - r'*W'*j*h +s'*Z'*j*h))-g;
(0.2*p1*j - 0.2*a'*v*j*b - 0.2*r'*w*j*b - 0.2*s'*z*j*b)- d;
(0.2*q1*j - 0.2*a'*v*j*b - 0.2*r'*w*j*g - 0.2*s'*z*j*g)- h];
%below is my call function;
fun=@TRIAL3; Xo=[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]; X=fsolve(fun,Xo)
%my error message Error using TRIAL3 (line 5) Not enough input arguments.
Error in fsolve (line 217) fuser = feval(funfcn{3},x,varargin{:});
Caused by: Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue.

采纳的回答

Torsten
Torsten 2018-6-12
fun = @(x)TRIAL3(x, V1,W1 ,W, w, z, Z1,Z, p, p1, q1, q, c1, V, v, j);
Xo = [1 1 1 1 1 1 1];
X = fsolve(fun,Xo)
  9 个评论
Honey Adams
Honey Adams 2018-6-12
I think it worked. Thank you so much. May I have your email address if you don't mind. You saved me after a week of trying to read soo many Matlab previous questions. I am glad for your assistance.
Honey Adams
Honey Adams 2018-6-14
Hello Tornsten,I would like to implement this same nonlinear equation with genetic algorithm.I keep getting not enough input argument,I would be glad if you could assist.Thanks for your time.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surrogate Optimization 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by