Please help me in genetic PID code

[LEFT]i try to optimize the pid controller through GA using matlab but i always i get different value of Kp,Ki, Kd from what i have
in the subject…can any one tell me whati the mistake in this code or give any genetic code to mimize error for PID

[SIZE=3]clear
Kp=1;
Ki=0;
Kd=0;
fitness = @gentPID;
numberOfVariables = 3;
opts = gaoptimset(‘PlotFcns’,{@gaplotbestf,@gaplotstopping},‘MutationFcn’, {@mutationuniform, 0.03})
opts.PopulationSize= 30;
opts.CrossoverFraction= 1
opts.PopulationType= 'doubleVector’
opts.Generations= 100
opts.PopInitRange=[-10;10];
opts.StallGenLimit=Inf;
opts.TimeLimit=Inf;
[x,fval] = ga(fitness,numberOfVariables,opts)

[/size]


[/left]

function fitness =gentPID(x,N,PlantS)
PlantNum=[1 ]; %default Numerator
PlantDen=[50 43 3]; %default Denumerator
PlantS=tf(PlantNum,PlantDen);%Trasfer function of plant
N=1000;
Kd=x(1);
Kp=x(2);
Ki=x(3);
PIDgain=[Kd Kp Ki];
PIDden=[1 0];
PIDreg = tf(PIDgain,PIDden); % Trasfer function of PID Controller

opp=series(PIDreg,PlantS); % Close Loop Transfer Function
cltf = feedback(opp,1,-1);
[y t]= step(cltf,1:1:N); % Step response of closed-loop system in time domain
error = 1-y;% IAE error =Integral of absolute value of Error
fitness = sum(abs(error));