フィルターのクリア

how to generate chromosome?

5 ビュー (過去 30 日間)
Mohammad Ali
Mohammad Ali 2020 年 8 月 13 日
回答済み: Sara Boznik 2020 年 8 月 15 日
Matlab Code for generating a random population of 40 chromosome having 20 genes each. Value of the genes are 0 and 1.

採用された回答

Sara Boznik
Sara Boznik 2020 年 8 月 15 日
Is maybe this what are you looking for?
chromo=40;
gene=20;
for i=1:1:chromo
for j=1:1:gene
pop=randi([0,1]);
A(:,j)=[pop]
end
B(i,:)=A(:,j)
end
[m,n]=size(B) %just for test
B is matrix with m=40 and n=20, so you have 40 choromosomes with each having 20 genes.
Best of luck.

その他の回答 (1 件)

Abdolkarim Mohammadi
Abdolkarim Mohammadi 2020 年 8 月 14 日
編集済み: Abdolkarim Mohammadi 2020 年 8 月 15 日
Assuming you want search agents in the rows and design variables in the columns:
PopulationSize = 40;
nvars = 20;
Population = randi ([0,1], [PopulationSize,nvars]);

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by