how to generate chromosome?

5 visualizaciones (últimos 30 días)
Mohammad Ali
Mohammad Ali el 13 de Ag. de 2020
Respondida: Sara Boznik el 15 de Ag. de 2020
Matlab Code for generating a random population of 40 chromosome having 20 genes each. Value of the genes are 0 and 1.

Respuesta aceptada

Sara Boznik
Sara Boznik el 15 de Ag. de 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.

Más respuestas (1)

Abdolkarim Mohammadi
Abdolkarim Mohammadi el 14 de Ag. de 2020
Editada: Abdolkarim Mohammadi el 15 de Ag. de 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]);

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by