calling a function for mutation operator but getting error
조회 수: 13 (최근 30일)
이전 댓글 표시
I am calling following function, but getting error (Undefined function or variable 'parent_genotype')
genotype = mutation_new(parent_genotype,mutation_rate,n_genes_mutated,total_jobs);
data in mutation_new.m file is as under
function genotype = mutation_new(parent_genotype,mutation_rate,n_genes_mutated,total_jobs)
population_size = 5;
mutation_rate = 0.1;
total_jobs=50;
parent_genotype = randperm(total_jobs);
b = parent_genotype;
population_matrix = zeros(population_size,total_jobs);
n_genes_mutated = length(parent_genotype)*mutation_rate;
for i = 1:n_genes_mutated/2
num1 = randi(total_jobs,1);
num2 = randi(total_jobs,1);
b([num1 num2]) = b([num2 num1]);
end
genotype = b;
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Genetic Algorithm에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!