In Matlab, say I have the following matrix, which represents a population of 10 individuals:

```
pop = [0 0 0 0 0; 1 1 1 0 0; 1 1 1 1 1; 1 1 1 0 0; 0 0 0 0 0; 0 0 0 0 0; 1 0 0 0 0; 1 1 1 1 1; 0 0 0 0 0; 0 0 0 0 0];

```

Where rows of `ones` and `zeros` define 6 different 'types' of individuals. 

```
a = [0 0 0 0 0];
b = [1 0 0 0 0];
c = [1 1 0 0 0];
d = [1 1 1 0 0];
e = [1 1 1 1 0];
f = [1 1 1 1 1];

```

I want to define the proportion/frequency of `a`, `b`, `c`, `d`, `e` and `f` in `pop`. 

I want to end up with the following list:

```
a = 0.5;
b = 0.1;
c = 0;
d = 0.2;
e = 0;
f = 0.2;

```

One way I can think of is by summing the rows, then counting the number of times each appears, and then sorting and indexing

```
sum_pop = sum(pop')';
x = unique(sum_pop);
N = numel(x);
count = zeros(N,1);
   for l = 1:N
      count(l) = sum(sum_pop==x(l));
   end
pop_frequency = [x(:) count/10];

```

But this doesn't quite get me what I want (i.e. when frequency = 0) and it seems there must be a faster way?