error in fsolve solving nonlinear equations
Show older comments
Hi I'm trying to solve nonlinear equations with the following code:
F = myfun(x)
F = [ x(1)-((500+0.85*(((0.711+0.56*15/100+0.73*(15/100)^2)*5.67*10^(-8)*(25+273.15)^4*(1-cos(30*pi/180))/2)-5.67*10^(-8)*(25+273.15)^4))*1.6*0.8*(1-0*2)*1-1.6*((32+6.4*2)*(x(5)-25)));
x(2)-(2068.5072425+(-20.1259571429)*x(4)+0.0701428571*x(4)^2+(56.5615102375+(-0.0892494524)*x(4)+(-0.0013878571)*x(4)^2)*x(5)+(0.669960831250007+(-0.001477845238096)*x(4)+0.000000357142857*x(4)^2)*x(5)^2);
x(3)-(373.160515+(-0.7728)*x(4)+0.0378095238*x(4)^2+((-4.03604873)+0.2014116*x(4)+0.0005034286*x(4)^2)*x(5)+((-0.22703617375)+0.003774373809524*x(4)+(-0.000001214285714)*x(4)^2)*x(5)^2);
x(2)-(70*(x(4)-40));
x(2)-(x(3)+x(1)-12*(x(4)-20))];
Then I run the follwing:
x0 = [-5; -5]; % Make a starting guess at the solution
options = optimoptions('fsolve','Display','iter'); % Option to display output
[x,fval] = fsolve(@myfun,x0,options) % Call solver
I got the following errors in workspace:
Attempted to access x(5); index out of bounds because numel(x)=2.
Error in myfun (line 2)
F = [
x(1)-((500+0.85*(((0.711+0.56*15/100+0.73*(15/100)^2)*5.67*10^(-8)*(25+273.15)^4*(1-cos(30*pi/180))/2)-5.67*10^(-8)*(25+273.15)^4))*1.6*0.8*(1-0*2)*1-1.6*((32+6.4*2)*(x(5)-25)));
Error in fsolve (line 217)
fuser = feval(funfcn{3},x,varargin{:});
Error in testes_auxiliares_eqnonlinear_v2 (line 3)
[x,fval] = fsolve(@myfun,x0,options) % Call solver
Can someone help me.
Accepted Answer
More Answers (0)
Categories
Find more on Systems of Nonlinear Equations in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!