am obtaining errors while solving equations by fsolve
2 次查看(过去 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 个评论
采纳的回答
Star Strider
2014-7-28
See if:
x0=[5,5,5,5,5];
x = fsolve(@myfun,x0);
improves things.
2 个评论
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 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!