Please help me to change to matlab languge
GENSIZE = 20
genepool = []
for i in range(0, GENSIZE):
dna = [random.choice(string.printable[:-5])for j in range(0, len(target))]
fitness = calc_fitness(dna, target)
candidate = {‘dna’: dna, ‘fitness’: fitness}
genepool.append(candidate)
here is the fitness function
function fitval = fitness(source, t)
fitval = 0;
for i = 1 : length(source)
fitval = fitval + (double(t(i)) – double(source(i))) ^ 2;
end
Expert Answer
A solution will be send to your mail shortly . . . .