# Not enough input arguments

1 view (last 30 days)
wyeen chow on 3 Dec 2021
Commented: Star Strider on 3 Dec 2021
Hi all, I running this code here but it always shows not enough input. Anyone willing to guide me through this ?
I still unfamilliar with the array part. Thank you in advance.
function[ F ,P1 ,Pl]=eldnba(x)
warning off;
data=[0.000299 10.1 671 150 455
0.000183 10.2 574 150 455
0.001126 8.8 374 20 130
0.001126 8.8 374 20 130
0.000205 10.4 461 150 470
0.000301 10.1 630 135 460
0.000364 9.8 548 135 465
0.000338 11.2 227 60 300
0.000807 11.2 173 25 162
0.001203 10.7 175 25 160
0.003586 10.2 186 20 80
0.005513 9.9 230 20 80
0.000371 13.1 225 25 85
0.001929 12.1 309 15 55
0.004447 12.4 323 15 55];
% Loss coefficients it should be squarematrix of size nXn where n is the no
% of plants
B=[ 0.0017 0.0012 0.0007 -0.0001 -0.0005 0.0002
0.0012 0.0014 0.0009 0.0001 -0.0006 -0.0001
0.0007 0.0009 0.0031 0.0000 -0.0010 -0.0006
-0.0001 0.0001 0.0000 0.0024 -0.0006 -0.0008
-0.0005 -0.0006 -0.0010 -0.0006 0.0129 -0.0002
-0.0002 -0.0001 -0.0006 -0.0008 -0.0002 0.0150];
% Demand (MW)
Pd=2630;
x=abs(x);
n=length(data(:,1));
for i=1:n-1
if x(i)>1
x(i)=1;
else
end
P(i)=data(i+1,14)+x(i)*(data(i+1,15)-data(i+1,14));
end
B11=B(1,1);
B1n=B(1,3:n);
Bnn=B(3:n,3:n);
A=B11;
BB1=2*B1n*P';
B1=BB1-1;
C1=P*Bnn*P';
C=Pd-sum(P)+C1;
x1=roots([A B1 C]);
% x=.5*(-B1-sqrt(B1^2-4*A*C))/A
x=abs(min(x1));
if x>data(1,15)
x=data(1,15);
else
end
if x<data(1,14)
x=data(1,14);
else
end
P1=[x P];
for i=1:n
F1(i)=data(i,1)* P1(i)^2+data(i,2)*P1(i)+data(i,3);
end
Pl=P1*B*P1';
lam=abs(sum(P1)-Pd-P1*B*P1');
F=sum(F1)+1000*lam;

Star Strider on 3 Dec 2021
Run this:
which abs -all
from a script or the Command Window, and post the results. I suspect there is another ‘abs’ function lurking sonewhere on the MATLAB search path that’s causing the problem.
.
wyeen chow on 3 Dec 2021
Thank you Star Strider. It does work, but will it effect my other part of the codes cause it based on a ant-lion optimization formula ?
Star Strider on 3 Dec 2021
My pleasure!
Re-name the additional ‘abs’ function to something else that does not ‘overshadow’ (conflict with) any existing MATLAB function, then update all references to it in the code that uses it. That is the only way I know of to solve those types of problems.
That could be tedious, however it is necessary. The MATLAB Editor can make this relatively straightforward to do, using the Find search-and-replace function in the top toolstrip. Only the function name, not the arguments, will need to change, so this should not require much effort.
.