I do some revisions to my equation but I still got no answer. It says that there is no enough input argument. Can someone please help me?

조회 수: 1(최근 30일)
John Marvin Miniano
John Marvin Miniano 2022년 5월 11일
댓글: Alex Sha 2022년 5월 11일
function f=rle(x)
f(1)=x(2)+x(3)+x(5)+x(7)-2758.6474;
f(2)=2*x(1) + 2*x(4) + 4*x(5)-5684.5402;
f(3)=x(2) +2*x(3)+x(4)-4292.1525;
f(4)=2*x(6)-6422.3564;
f(5)=((x(1)^3)*(x(2))/(x(4)*x(5)))-(1893.12055);
f(6)=(x(1)*x(3))/(x(2)*x(4))-(0.7631343);
f(7)=((x(1)*x(2))/x(4))-(32.200985);
>> x0=[150;150;150;150;150;150;150];
x=fsolve(rle,x0);
Not enough input arguments.
Error in rle (line 2)
f(x)=x(2)+x(3)+x(5)+x(7)-2758.6474;

채택된 답변

VBBV
VBBV 2022년 5월 11일
편집: VBBV 2022년 5월 11일
x0=[150;150;150;150;150;150;150];
% x = 1:7; % give input vector to fucntion
sol=fsolve(@rle,x0) % call the function using function handle
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.
sol = 7×1
1.0e+03 * 0.1914 0.2365 1.3252 1.4052 0.6228 3.2112 0.5741
plot(sol)
function f=rle(x)
f(1)=x(2)+x(3)+x(5)+x(7)-2758.6474;
f(2)=2*x(1) + 2*x(4) + 4*x(5)-5684.5402;
f(3)=x(2) +2*x(3)+x(4)-4292.1525;
f(4)=2*x(6)-6422.3564;
f(5)=((x(1)^3)*(x(2))/(x(4)*x(5)))-(1893.12055);
f(6)=(x(1)*x(3))/(x(2)*x(4))-(0.7631343);
f(7)=((x(1)*x(2))/x(4))-(32.200985);
end
  댓글 수: 1
Alex Sha
Alex Sha 2022년 5월 11일
There are multi-solutions:
No. 1 2
x1 -206.504477863007 191.355831175864
x2 -249.192353855846 236.471139659005
x3 1471.63884269976 1325.22038022388
x4 1598.06716845633 1405.24059989323
x5 725.353704703337 622.836834465451
x6 3211.1782 3211.1782
x7 810.847206452752 574.119045651664

댓글을 달려면 로그인하십시오.

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by