function myEq
b1=1000;
b2=100;
c=50;
t=0.76;
T=950;
n=5;
x0 = [1 1 1 1 1 1];
opts = optimoptions('fsolve', 'Algorithm', 'levenberg-marquardt');
sol = fsolve(@fun, x0, opts)
test = fun(sol)
function eq = fun(x)
Sum = x(1);
R1 = x(2);
R2 = x(3);
R3 = x(4);
R4 = x(5);
R5 = x(6);
eq(1)=(R1-R2)-((1+t)*T*(R2^t-R1^t)+50)/b2;
eq(2)=(R2-R3)-((1+t)*T*(R3^t-R2^t)+50)/b2;
eq(3)=(R3-R4)-((1+t)*T*(R4^t-R3^t)+50)/b2;
eq(4)=(R4-R5)-((1+t)*T*(R5^t-R4^t)+50)/b2;
eq(5)=Sum-(n*R5+(R4-R5)+2*(R3-R4)+3*(R2-R3)+4*(R1-R2));
eq(6)=R1-(b1-b2*Sum-(1+t)*T*R1^t-c)/b2;
eq(7)=R2-(b1-b2*Sum-(1+t)*T*R2^t-2*c)/b2;
eq(8)=R3-(b1-b2*Sum-(1+t)*T*R3^t-3*c)/b2;
eq(9)=R4-(b1-b2*Sum-(1+t)*T*R4^t-4*c)/b2;
eq(10)=R5-(b1-b2*Sum-(1+t)*T*R5^t-5*c)/b2;
end
end
gives acceptabe results:
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
<stopping criteria details>
sol =
1.5076 0.3566 0.3279 0.2998 0.2722 0.2453
test =
1.0e-09 *
Columns 1 through 9
-0.0108 -0.0043 0.0059 0.1264 -0.0998 -0.0157 -0.0049 -0.0006 -0.0065
Column 10
-0.1329