Hi everyone, I know this error is self-explanatory. In line 34 of the attached code, I indexed to the end of the independent variable, thinking that it will prevent the error. There seems to be still yet another small think that lead to this error
Index exceeds the number of array elements (1). Error in my_fsolve3>@(x)x(i)+2.*G(i)-((H(i).*A.*x(i))/(x(i).^2+A.*x(i)+A*B))-2.*((H(i).*A*B)/(x(i).^2+A.*x(i)+A*B))-((I(i).*C.*x(i))/(x(i).^2+C.*x(i)+C*D))-2.*((I(i).*C.*D)/(x(i).^2+C.*x(i)+C*D))-E./x(i) (line 37) x(i) = fsolve(@(x) x(i) + 2.* G(i) - ((H(i).* A.*x(i))/(x(i).^2 + A.*x(i) + A*B))- 2.*((H(i).*A*B)/(x(i).^2 ... Error in fsolve (line 242) fuser = feval(funfcn{3},x,varargin{:}); Error in my_fsolve3 (line 37) x(i) = fsolve(@(x) x(i) + 2.* G(i) - ((H(i).* A.*x(i))/(x(i).^2 + A.*x(i) + A*B))- 2.*((H(i).*A*B)/(x(i).^2 ... Caused by: Failure in initial objective function evaluation. FSOLVE cannot continue. >>
Debugging points me to line 37.
Please help.
Best Answer