how to solve this error? Objective function is returning undefined values at initial point. FSOLVE cannot continue.
Show older comments
x0=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0];
opts=[];
x=fsolve(@fun,x0,opts)
function y=fun(x)
H=7.9;
D=0.3145;
P=100;
V10=0;
h=0.79;
e1=0.4;
Q=0;
R=32131;%单位kN·m²
p0=0.368*187.5*1.67*((x(3)*D^2/0.0078).^0.333);
p1=0.368*4392.2/16*1.67*((x(4)*D^2/0.0078).^0.333);
p2=0.368*5784.4/16*1.67*((x(5)*D^2/0.0072).^0.333);
p3=0.368*7176.6/16*1.67*((x(6)*D^2/0.0086).^0.333);
p4=0.368*8568.8/16*1.67*((x(7)*D^2/0.0047).^0.333);
p5=0.368*562.5*2*((x(8)*D^2/0.0064).^0.333);
p6=0.368*562.5*6.6*((x(9)*D^2/0.0017).^0.333);
p7=0.368*562.5*20.38*((x(10)*D^2/4.694898747058535e-04).^0.333);
p8=0.368*562.5*2.22*((x(11)*D^2/0.0057).^0.333);
p9=0.368*562.5*1.8*((x(12)*D^2/0.0072).^0.333);
p10=0.368*562.5*6.08*((x(13)*D^2/0.0018).^0.333);
%a=R(i-1)
a=R;
%b=-2R(i-1)-2R(i-1)+Qh^2
b=-4*R+Q*h^3;
%c=R(i-1)+4R(i)+R(i+1)-2Qh^2+Epyih^4
c0=6*R-2*Q*h^2+p0/x(3)*h^4;
c1=6*R-2*Q*h^2+p1/x(4)*h^4;
c2=6*R-2*Q*h^2+p2/x(5)*h^4;
c3=6*R-2*Q*h^2+p3/x(6)*h^4;
c4=6*R-2*Q*h^2+p4/x(7)*h^4;
c5=6*R-2*Q*h^2+p5/x(8)*h^4;
c6=6*R-2*Q*h^2+p6/x(9)*h^4;
c7=6*R-2*Q*h^2+p7/x(10)*h^4;
c8=6*R-2*Q*h^2+p7/x(11)*h^4;
c9=6*R-2*Q*h^2+p9/x(12)*h^4;
c10=6*R-2*Q*h^2+p10/x(13)*h^4;
%-2R(i)-2R(i+1)+Qh^2
d=-4*R+Q*h^3;
%e=R(i+1)
e=R;
y=[R*(x(2)-2*x(3)+x(4))-P*e1;...
R/2*(x(1)-2*x(2)+2*x(4)-x(5))-P;...
a*x(1)+b*x(2)+c0*x(3)+d*x(4)+e*x(5);...
a*x(2)+b*x(3)+c1*x(4)+d*x(5)+e*x(6);...
a*x(3)+b*x(4)+c2*x(5)+d*x(6)+e*x(7);...
a*x(4)+b*x(5)+c3*x(6)+d*x(7)+e*x(8);...
a*x(5)+b*x(6)+c4*x(7)+d*x(8)+e*x(9);...
a*x(6)+b*x(7)+c5*x(8)+d*x(9)+e*x(10);...
a*x(7)+b*x(8)+c6*x(9)+d*x(10)+e*x(11);...
a*x(8)+b*x(9)+c7*x(10)+d*x(11)+e*x(12);...
a*x(9)+b*x(10)+c8*x(11)+d*x(12)+e*x(13);...
a*x(10)+b*x(11)+c9*x(12)+d*x(13)+e*x(14);...
a*x(11)+b*x(12)+c10*x(13)+d*x(14)+e*x(15);...
x(14)-2*x(13)+x(12);...
R/(2*h^3)*(x(11)-2*x(12)+2*x(14)-x(15))]
end
Answers (2)
Umeshraja
on 5 Jan 2025
0 votes
The objective function supplied to 'fsolve' must return a vector without any Inf or NaN entries.
Please refer to the following documentation on 'fsolve' function
Hope this helps!
In the computation of c0,...,c10, you divide by x(3),...,x(13), thus by 0 because x0 = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] .
After changing x0, you will most probably get complex values for the x-vector because some of the x become negative and you use x(i).^0.333 for 3<=i<=13 in your code.
Categories
Find more on Semantic Segmentation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!