function f=matchesrnd(n,m) % f is the observed number of matches of n items over m trials. f=[]; for i=1:m f=[f sum(permuternd(n)==(1:n))]; end