Uniform crossover with boolean population

2 ビュー (過去 30 日間)
Sandi J
Sandi J 2018 年 11 月 5 日
回答済み: Walter Roberson 2018 年 11 月 5 日
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?

採用された回答

Walter Roberson
Walter Roberson 2018 年 11 月 5 日
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 件)

カテゴリ

Help Center および File ExchangeGenomics and Next Generation Sequencing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by