counts = accumarray(M([2 1],:) .', ones(size(M, 2),1))
perc = counts ./ sum(counts, 2) * 100
Rows of perc will correspond to values in row 2 of M. Columns will correspond to values in row 1 of M.
The code should be made more robust for the case where the values are not consecutive positive integers.