www.gusucode.com > GAVPai_Book_MathworksCntrlFileEx_May2019 > GAVPai_Book_MathworksCntrlFileEx_May2019/comp_fitness.m
% compute fitness function values of the population of individuals using % equation [4.19] function popln_fitness = comp_fitness(popln_mat, premia_dat, covariance_dat, psi_fun) [popln_size, ~]=size(popln_mat); for i = 1: popln_size weight = popln_mat(i,:); objfunc_val(i) = -((premia_dat * weight')/ sqrt(weight*covariance_dat * weight')) + psi_fun(i); end popln_fitness = objfunc_val ; end