Question: I have written a script that loop trough several `matrices`.
The output I am getting looks like this:

```
10,40,50
20,60,50,80
30,50,70,110
30,70,110

```

and so on...

What I want to do is to count how many unique profiles there exist, if one matrix contain `10,40,50` it will be counted as one profile labeled (10,40,50) when if it will find another matrix that is exactly the same (10,40,50) it should print: 10,40,50 found 2 time and so on iteratively.

So to sum it up, I have a script that runs trough matrices. They contain of different values that repeat themselves from time to time, I want to count all existent unique profiles. Let say we input this:

```
10,40,50
10,40,50
10,40,50
30,50,70,110
20,60,50,80
30,50,70,110
10,40,50
10,40,50

```

The output should be (the counting could be outputted however):

```
10,40,50 found 5 time

20,60,50,80 found 1 time

30,50,70,110 found 2 time

```

Help is very, very much appreciated, doing this for a hobby project.

Edit: It's not a cell array I am using, it is a <1x500> vector I am looping trough.

Answer: 
(It's a pity that the `unique` function doesn't work on a cell array of numeric vectors.)

You can do it as follows:

```
x = { [10,40,50];
      [10,40,50]
      [10,40,50];
      [30,50,70,110];
      [20,60,50,80];
      [30,50,70,110];
      [10,40,50];
      [10,40,50] };
[ii, jj] = ndgrid(1:numel(x)); % indices of all pairs
m = cellfun(@isequal, x(ii), x(jj)); % all pairwise comparisons
[u, v] = unique(m, 'rows', 'stable'); % unique rows, and their indices
count = sum(u,2); % result: number of repetitions
unique_x = x(v); % result: unique vectors

```

This gives

```
>> celldisp(unique_x)
unique_x{1} =
    10    40    50
unique_x{2} =
    30    50    70   110
unique_x{3} =
    20    60    50    80
>> count
count =
     5
     2
     1

```

To display with the desired format:

```
for n = 1:numel(unique_x)
    disp([mat2str(unique_x{n}) ' found ' num2str(count(n)) ' time(s)'])
end

```

prints

```
[10 40 50] found 5 time(s)
[30 50 70 110] found 2 time(s)
[20 60 50 80] found 1 time(s)

```

If the results are obtained in a loop: collect them into a cell array and then apply the above:

```
x = cell(1,num_iter); % preallocate if possible
for iter_index = 1:num_iter
    % Do stuff that gives a vector iter_result as a result
    x{iter_index} = iter_result;
end
% Now apply above code to x

```
I guess your output of your script is a cell array, since my kind of ad-hoc answer is based on this assumption. So, if the output of your script is:

```
output = {[10,40,50];
          [10,40,50];
          [10,40,50];
          [30,50,70,110];
          [20,60,50,80];
          [30,50,70,110];
          [10,40,50];
          [10,40,50]};

```

We can convert your output in string format. Lame, but works :) :

```
tmp = cellfun(@num2str,output,'UniformOutput',false);

```

And then we use `unique` function:

```
[a,b,c]=unique(tmp);

```

Where `a` is the unique strings of `tmp`, `b` is the first occurrence of the string in tmp and `c` shows which element in `tmp` corresponds to which element in `a`, i.e. maps `tmp` onto `a`. All we have to do now is to count how many `1`-s, `2`-s, `3`-s etc in the vector `c`. I prefer to use a simple loop for this purpose:

```
for k = 1:length(b)
    n(k) = nnz(c == k);
    disp(['[',a{k},'] found ',num2str(n(k)),' time(s)'])
end

```

So, the final output is:

```
[10  40  50] found 5 time(s)
[20  60  50  80] found 1 time(s)
[30   50   70  110] found 2 time(s)

```

Hope that helps