am obtaining errors while solving equations by fsolve

1 次查看(过去 30 天)
my coding function F = myfun(x) F=[(((x(5)*(-x(1)*x(3))+(x(2)*x(4))*0.15335)+((x(5)*(1+x(1)+x(2))*0.034077)))/((1+(x(5)*(1+x(1)+x(2)))*0.15335))^2); ((((x(5)*(-x(1)*x(3)*(-x(3)-1)*(-x(3)-2)+(x(2)*x(4))*(x(4)-1)*(x(4)-2))*0.15335)+2*x(5)*(-x(1)*x(3))+(x(2)*x(4)))*0.034077+(x(5)*(1+x(1)+x(2)))*(-0.15335))*((1+(x(5)*(-x(1)*x(3))+(x(2)*x(4))*0.15335))^2)-(2*(((x(5)*(-x(1)*x(3))+(x(2)*x(4)))*0.15335)+((x(5)*(1+x(1)+x(2))*0.034077)))/((1+(x(5)*(1+x(1)+x(2)))*0.15335))^3)); ((x(5)*(-x(1)*x(3)*(-x(3)-1)*(-x(3)-2))+((x(2)*x(4))*(x(4)-1)*(x(4)-2)))*0.15335+(3*(x(5)*(-x(1)*x(3)*(-x(3)-1))+((x(2)*x(4))*(x(4)-1)))*0.034077)+(3*((x(5)*(-x(1)*x(3)))+(x(2)*x(4)))*(-0.15335))+((x(5)*(1+x(1)+x(2)))*(-0.383645))*((1+(x(5)*(1+x(1)+x(2)))*0.15335)^2)-(6*(2*((x(5)*(-x(1)*x(3))+(x(2)*x(4)))*0.15335)+(x(5)*(1+x(1)+x(2))*0.034077)))*((((x(5)*(-x(1)*x(3)*(-x(3)-1)*(-x(3)-2)+(x(2)*x(4))*(x(4)-1)*(x(4)-2))*0.15335)+2*x(5)*(-x(1)*x(3))+(x(2)*x(4)))*0.034077+(x(5)*(1+x(1)+x(2)))*(-0.15335))*((1+(x(5)*(-x(1)*x(3))+(x(2)*x(4))*0.15335))^2)-(6*(((x(5)*(-x(1)*x(3))+(x(2)*x(4)))*0.15335)+((x(5)*(1+x(1)+x(2))*0.034077))))/((1+(x(5)*(1+x(1)+x(2)))*0.15335))^4)); (((x(5)*((-x(1)*x(3))*(-x(3)-1)*(-x(3)-2)*(-x(3)-3))+((x(2)*x(4))*(x(4)-1)*(x(4)-2)*(x(4)-3)))*0.15335)+(4*(x(5)*(-x(1)*x(3)*(-x(3)-1)*(-x(3)-2))+((x(2)*x(4))*(x(4)-1)*(x(4)-2)))*0.034077)+(6*(x(5)*(-x(1)*x(3)*(-x(3)-1))+((x(2)*x(4))*(x(4)-1)))*(-0.15335))+(4*((x(5)*(-x(1)*x(3)))+(x(2)*x(4)))*(-0.383645))+(((x(5)*(-x(1)*x(3)))+(x(2)*x(4))*(-0.5437)))*(((1+(x(5)*(-x(1)*x(3))+(x(2)*x(4))*0.15335))^3))-((6*((x(5)*(-x(1)*x(3)*(-x(3)-1)*(-x(3)-2)+(x(2)*x(4))*(x(4)-1)*(x(4)-2))*0.15335)+2*x(5)*(-x(1)*x(3))+(x(2)*x(4)))*0.034077+((x(5)*(1+x(1)+x(2)))*(-0.15335)))^2)*((1+(x(5)*(-x(1)*x(3))+(x(2)*x(4))*0.15335))^2)-(8*(((x(5)*(-x(1)*x(3))+(x(2)*x(4)))*0.15335)+((x(5)*(1+x(1)+x(2))*0.034077))))*((x(5)*(-x(1)*x(3)*(-x(3)-1)*(-x(3)-2))+((x(2)*x(4))*(x(4)-1)*(x(4)-2)))*0.15335+(3*(x(5)*(-x(1)*x(3)*(-x(3)-1))+((x(2)*x(4))*(x(4)-1)))*0.034077)+(3*((x(5)*(-x(1)*x(3)))+(x(2)*x(4)))*(-0.15335))+((x(5)*(1+x(1)+x(2)))*(-0.383645))*((1+(x(5)*(1+x(1)+x(2)))*0.15335)^2)-(6*(2*((x(5)*(-x(1)*x(3))+(x(2)*x(4)))*0.15335)+(x(5)*(1+x(1)+x(2))*0.034077)))*((((x(5)*(-x(1)*x(3)*(-x(3)-1)*(-x(3)-2)+(x(2)*x(4))*(x(4)-1)*(x(4)-2))*0.15335)+2*x(5)*(-x(1)*x(3))+(x(2)*x(4)))*0.034077+(x(5)*(1+x(1)+x(2)))*(-0.15335))*((1+(x(5)*(-x(1)*x(3))+(x(2)*x(4))*0.15335))^2)-(6*(x(5)*(-x(1)*x(3))+(x(2)*x(4)))*0.15335)+((x(5)*(1+x(1)+x(2))*0.034077)))))/(((1+(x(5)*(-x(1)*x(3))+(x(2)*x(4))*0.15335))^5)); ((((x(5)*((-x(1)*x(3))*(-x(3)-1)*(-x(3)-2)*(-x(3)-3)*(-x(3)-4))+((x(2)*x(4))*(x(4)-1)*(x(4)-2)*(x(4)-3)*(-x(4)-4)))*0.153355)+(5*(x(5)*((-x(1)*x(3))*(-x(3)-1)*(-x(3)-2)*(-x(3)-3))+((x(2)*x(4))*(x(4)-1)*(x(4)-2)*(x(4)-3)))*0.034077)+(10*(x(5)*(-x(1)*x(3)*(-x(3)-1)*(-x(3)-2))+((x(2)*x(4))*(x(4)-1)*(x(4)-2)))*(-0.15335))+(10*(x(5)*(-x(1)*x(3)*(-x(3)-1)+((x(2)*x(4))*(x(4)-1)))*(-0.383645)))+(5*((x(5)*(-x(1)*x(3)))+(x(2)*x(4)))*(-0.5437)+((x(5)*(1+x(1)+x(2)))*(-0.927345))))*((1+(x(5)*(-x(1)*x(3))+(x(2)*x(4)))*0.15335)^4)-(20*(((x(5)*(-x(1)*x(3)*(-x(3)-1)*(-x(3)-2)+(x(2)*x(4))*(x(4)-1)*(x(4)-2))*0.15335)+2*x(5)*(-x(1)*x(3))+(x(2)*x(4)))*0.034077+(x(5)*(1+x(1)+x(2)))*(-0.15335)))+(((x(5)*((-x(1)*x(3))*(-x(3)-1)*(-x(3)-2)*(-x(3)-3))+((x(2)*x(4))*(x(4)-1)*(x(4)-2)*(x(4)-3)))*0.15335)+(4*(x(5)*(-x(1)*x(3)*(-x(3)-1)*(-x(3)-2))+((x(2)*x(4))*(x(4)-1)*(x(4)-2)))*0.034077)+(6*(x(5)*(-x(1)*x(3)*(-x(3)-1))+((x(2)*x(4))*(x(4)-1)))*(-0.15335))+(4*((x(5)*(-x(1)*x(3)))+(x(2)*x(4)))*(-0.383645))+(((x(5)*(-x(1)*x(3)))+(x(2)*x(4))*(-0.5437)))*(((1+(x(5)*(-x(1)*x(3))+(x(2)*x(4))*0.15335))^3))-((6*((x(5)*(-x(1)*x(3)*(-x(3)-1)*(-x(3)-2)+(x(2)*x(4))*(x(4)-1)*(x(4)-2))*0.15335)+2*x(5)*(-x(1)*x(3))+(x(2)*x(4)))*0.034077+((x(5)*(1+x(1)+x(2)))*(-0.15335)))^2)*((1+(x(5)*(-x(1)*x(3))+(x(2)*x(4))*0.15335))^2)-(8*(((x(5)*(-x(1)*x(3))+(x(2)*x(4)))*0.15335)+((x(5)*(1+x(1)+x(2))*0.034077))))*((x(5)*(-x(1)*x(3)*(-x(3)-1)*(-x(3)-2))+((x(2)*x(4))*(x(4)-1)*(x(4)-2)))*0.15335+(3*(x(5)*(-x(1)*x(3)*(-x(3)-1))+((x(2)*x(4))*(x(4)-1)))*0.034077)+(3*((x(5)*(-x(1)*x(3)))+(x(2)*x(4)))*(-0.15335))+((x(5)*(1+x(1)+x(2)))*(-0.383645))*((1+(x(5)*(1+x(1)+x(2)))*0.15335)^2)-(6*(2*((x(5)*(-x(1)*x(3))+(x(2)*x(4)))*0.15335)+(x(5)*(1+x(1)+x(2))*0.034077)))*((((x(5)*(-x(1)*x(3)*(-x(3)-1)*(-x(3)-2)+(x(2)*x(4))*(x(4)-1)*(x(4)-2))*0.15335)+2*x(5)*(-x(1)*x(3))+(x(2)*x(4)))*0.034077+(x(5)*(1+x(1)+x(2)))*(-0.15335))*((1+(x(5)*(-x(1)*x(3))+(x(2)*x(4))*0.15335))^2)-(6*(x(5)*(-x(1)*x(3))+(x(2)*x(4)))*0.15335)+((x(5)*(1+x(1)+x(2))*0.034077))))))/(((1+(x(5)*(-x(1)*x(3))+(x(2)*x(4))*0.15335))^6))]; x0=[5,5]; fslove(@myfun,x0); end
am getting errors
my errors Error in ==> myfun at 2 F=[(((x(5)*(-x(1)*x(3))+(x(2)*x(4))*0.15335)+((x(5)*(1+x(1)+x(2))*0.034077)))/((1+(x(5)*(1+x(1)+x(2)))*0.15335))^2);
Error in ==> fsolve at 248 fuser = feval(funfcn{3},x,varargin{:});
Caused by: Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue.
??? Input argument "x" is undefined.
Error in ==> myfun at 2 F=[(((x(5)*(-x(1)*x(3))+(x(2)*x(4))*0.15335)+((x(5)*(1+x(1)+x(2))*0.034077)))/((1+(x(5)*(1+x(1)+x(2)))*0.15335))^2); >>
kindly help me out to solve the errors
  2 个评论
Matt J
Matt J 2014-7-28
编辑:Matt J 2014-7-28
The code you've shown cannot be the actual code you are running. You have misspelled "fsolve", for example, which should have produced different error messages than what you've shown.
sabarish
sabarish 2014-7-30
sorry Mr.Matt j,i misspelled while here Attempted to access x(5); index out of bounds because numel(x)=2.
Error in ==> myfun at 2 F=[(((x(5)*(-x(1)*x(3))+(x(2)*x(4))*0.15335)+((x(5)*(1+x(1)+x(2))*0.034077)))/((1+(x(5)*(1+x(1)+x(2)))*0.15335))^2);
Error in ==> fsolve at 248 fuser = feval(funfcn{3},x,varargin{:});
Caused by: Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue. am getting here while running with mfile. and also if i give command ordinarily outside the mfile means gettingerror like this Attempted to access x(5); index out of bounds because numel(x)=2.
Error in ==> myfun at 2 F=[(((x(5)*(-x(1)*x(3))+(x(2)*x(4))*0.15335)+((x(5)*(1+x(1)+x(2))*0.034077)))/((1+(x(5)*(1+x(1)+x(2)))*0.15335))^2);
Error in ==> fsolve at 248 fuser = feval(funfcn{3},x,varargin{:});
Caused by: Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue.
please help me to figure out to find errors

请先登录,再进行评论。

采纳的回答

Star Strider
Star Strider 2014-7-28
See if:
x0=[5,5,5,5,5];
x = fsolve(@myfun,x0);
improves things.
  2 个评论
sabarish
sabarish 2014-7-30
thanks Mr.Star Strider. but it producing another error ??? Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N) to change the limit. Be aware that exceeding your available stack space can crash MATLAB and/or your computer.
Error in ==> optimget>optimgetfast
Caused by: Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue. Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue. Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue.
i tried to improve my stack size.but while am increasing my sixe my matlab programme automatically quit the all windows. what i do to solve the equatios
Star Strider
Star Strider 2014-7-30
The RecursionLimit message means that you are calling fsolve from within your function.
Remove all calls to fsolve within your function. All calls to fsolve should be outside your function, in your main script.

请先登录,再进行评论。

更多回答(1 个)

sabarish
sabarish 2014-8-8
thanks for your help.

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by