www.gusucode.com > GAVPai_Book_MathworksCntrlFileEx_May2019 > GAVPai_Book_MathworksCntrlFileEx_May2019/EMNP_gen_longshort_popln.m
% Generate initial poplulation for long and short positions in the portfolio (positive and negative weights) function longshort_popln = EMNP_gen_longshort_popln(poplnsize, Lcol,Scol, Longlowbound, Longupbound, Shortlowbound, Shortupbound) longshort_popln =zeros(poplnsize, Lcol+Scol); longshort_popln(1:poplnsize, 1:Lcol) = Longlowbound + (Longupbound-Longlowbound).*rand(poplnsize, Lcol); longshort_popln(1:poplnsize, Lcol+1:Lcol+Scol) = Shortlowbound + (Shortupbound-Shortlowbound).*rand(poplnsize, Scol);