how to generate chromosome?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Mohammad Ali
am 13 Aug. 2020
Beantwortet: Sara Boznik
am 15 Aug. 2020
Matlab Code for generating a random population of 40 chromosome having 20 genes each. Value of the genes are 0 and 1.
0 Kommentare
Akzeptierte Antwort
Sara Boznik
am 15 Aug. 2020
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.
0 Kommentare
Weitere Antworten (1)
Abdolkarim Mohammadi
am 14 Aug. 2020
Bearbeitet: Abdolkarim Mohammadi
am 15 Aug. 2020
Assuming you want search agents in the rows and design variables in the columns:
PopulationSize = 40;
nvars = 20;
Population = randi ([0,1], [PopulationSize,nvars]);
0 Kommentare
Siehe auch
Kategorien
Mehr zu Biotech and Pharmaceutical 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!