function B = selection(Population,NoAttack,N) Fitness=NoAttack; AvgFitness=mean(Fitness); ScaledFitness=Fitness/AvgFitness; roulette=cumsum(ScaledFitness); for i=1:N rnd_num=max(roulette)*rand; for j=1:N if roulette(j)>rnd_num B(:,:,i)=Population(:,:,j); break; end end end end