Azzera filtri
Azzera filtri

Uniform crossover with boolean population

1 visualizzazione (ultimi 30 giorni)
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?

Risposta accettata

Walter Roberson
Walter Roberson il 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.

Più risposte (0)

Categorie

Scopri di più su Genomics and Next Generation Sequencing in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by