Uniform crossover with boolean population
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Sandi J
le 5 Nov 2018
Réponse apportée : Walter Roberson
le 5 Nov 2018
I have this code in matlab to find 'uniform crossover' for the same vector W
W=[12,5,6,78,9,3];
%Parameters
N=2;
G=10;
Pop=round(rand([N,G]));
%%Uniform crossover
id=logical(round(rand(size(pop)))); %index of genome from W2
Pop2=Pop(W(1:2:end),:);%Set Pop2=Pop W1
P2A=Pop(W(2:2:end),:);%Assemble Pop2 W2
Pop2(id)=P2A(id);%combine W1 and W2
I got an error message at the last part of the code : Index Exceeds Matrix Dimensions. How can i solve the error?
0 commentaires
Réponse acceptée
Walter Roberson
le 5 Nov 2018
Pop is a different variable than pop. id will be the same size as pop.
Pop2 and P2A are formed by taking 3 subset rows from Pop. You then try to index them at id which is the full size of pop. That will fail unless pop is 3 or fewer rows and has no more columns than Pop does.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Genomics and Next Generation Sequencing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!