Hey, nice code.
I got an error for small populations and small genomes, and solved it by changing line 132 from "fitnessVals=ones(popSize,1);" to "fitnessVals=ones(1,popSize);". Please let me know if that change is valid or Im braking something in the code!