Error in the code metioned below
Mostrar comentarios más antiguos
%%Fitness function
function MCWQIAVG = mytrial(D1,D2,D3)
FEavgx = 0;
FEavgy = 0;
FEavgz = 0;
for t = 1:26
x = D1*exp(0.03*t);
if x>=0 && x<=0.1
FE = 1;
end
if x>0.1 && x<0.2
FE = -10*x+2;
end
if x>=0.2 && x<=0.5
FE = 0;
end
if x>0.5 && x<0.6
FE = 10*x-5;
end
if x>=0.6 && x<=1
FE = 1;
end
FEavgx = (FEavgx + FE)/2;
end
for t = 1:26
x = D2*exp(0.03*t);
if x>=0 && x<=0.1
FE = 1;
end
if x>0.1 && x<0.2
FE = -10*x+2;
end
if x>=0.2 && x<=0.5
FE = 0;
end
if x>0.5 && x<0.6
FE = 10*x-5;
end
if x>=0.6 && x<=1
FE = 1;
end
FEavgy = (FEavgy + FE)/2;
end
for t = 1:26
x = D3*exp(0.03*t);
if x>=0 && x<=0.1
FE = 1;
end
if x>0.1 && x<0.2
FE = -10*x+2;
end
if x>=0.2 && x<=0.5
FE = 0;
end
if x>0.5 && x<0.6
FE = 10*x-5;
end
if x>=0.6 && x<=1
FE = 1;
end
FEavgz = (FEavgz + FE)/2;
end
MCWQIx = 100-(FEavgx/(0.05*FEavgx+0.05));
MCWQIy = 100-(FEavgy/(0.05*FEavgy+0.05));
MCWQIz = 100-(FEavgz/(0.05*FEavgz+0.05));
MCWQIAVG = (MCWQIx + MCWQIy + MCWQIz)/3;
end
%%this is the fitness function that I have defined and the main portion is mentioned below
rng default
fitnessfcn = @mytrial
nvars = 3;
lb = [0.2,0.2,0.2];
ub = [0.4,0.4,0.4];
[x,favl]= ga(fitnessfcn,nvars,lb,ub)
%they are showing an error in the main portion mentioned above
%need help in correcting the error
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Linear Predictive Coding en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!