www.gusucode.com > GAVPai_Book_MathworksCntrlFileEx_May2019 > GAVPai_Book_MathworksCntrlFileEx_May2019/realnum_unifrm_mutation.m

    
function mutated_popln = realnum_unifrm_mutation(chromo_popln, popln_size, genes)
mut_rate = 0.01; 
gene_low = 0;
gene_high = 1;

 for i = 1 : popln_size
     for j = 1 : genes
         rno = rand;
         if (rno < mut_rate) % mutate the gene
             chromo_popln(i,j) = gene_low + rno * (gene_high-gene_low);
         end
     end
 end
 mutated_popln = chromo_popln;