calling a function for mutation operator but getting error

16 ビュー (過去 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 Center および File ExchangeGenetic Algorithm についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by