am obtaining errors while solving equations by fsolve

조회 수: 2 (최근 30일)
sabarish
sabarish 2014년 7월 28일
댓글: Star Strider 2014년 8월 8일
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에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by