Filter löschen
Filter löschen

Uniform crossover with boolean population

1 Ansicht (letzte 30 Tage)
Sandi J
Sandi J am 5 Nov. 2018
Beantwortet: Walter Roberson am 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?

Akzeptierte Antwort

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

Weitere Antworten (0)

Kategorien

Mehr zu Genomics and Next Generation Sequencing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by