function P = Mutation(C,pm) % P = Mutation(C,pm) %This operator takes an n by s input matrix C whose rows are binary strings %of a genetic algorithm population, and goes through, bit-by-bit, mutating %each entry (i.e., 1 to 0, or 0 to 1) with probability pm. The input pm %(mutation probability) is optional, with default = 0.01. The output %matrix P has the same size as C and is the resulting mutated population. [n s]=size(C); if nargin<2, pm = 0.01; end P=C; for i=1:n, for j=1:s if rand