calling a function for mutation operator but getting error

조회 수: 13 (최근 30일)
Bilal Khurshid
Bilal Khurshid 2016년 10월 10일
편집: Walter Roberson 2016년 10월 10일
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개)

카테고리

Help CenterFile Exchange에서 Genetic Algorithm에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by