Here is the program I run: function out = CointPairs(PriceMat, Symbols) out=[]; NofStocks = size(PriceMat, 2); CointMatrix= zeros(NofStocks); [rows, cols] = find(CointMatrix); CointPairs = [rows, cols]; **cf= (CointPairs(:,1)-CointPairs(:,2))==0;** CointPairs(cf,:) ...