for i=1:26 m(i,:) = sum(char(lower(a))'==i+96); for i=65:90 m(i,:) = sum(char(upper(a))'==i); end m = (m'*m)^3; c = find(m(b, :)); c = find(m(b,:));