I have a set of data looks like this:
data =
4 35
4 36
4 37
4 39
4 50
6 24
6 35
6 36
6 39
6 50
6 78
10 24
10 35
10 36
10 39
...
The actual matrix is in the order of 70000 X 2. What I want is to form a matrix containing all the unique data pair, so each element is not the same as the previous ones, would be look like
result =
4 35
6 24
10 36
I am think about a method like this
Step 1. find out all the index of unique column 1, in this case would be
index =
1
6
12
Step 2. Do a for-loop like this
result = data(index);
for j = 1:length(index)
if result(j,2) == result(j-1,2)
result(j) = data(index+1)
end
end
Here comes a problem, I have the possibility of getting some result like this
4 35
6 24
10 35
Then it is not unique. However, I don't want to write something like
if result(j,2) = result(j-1,2) ...
or result(j,2) = result(j-2,2) ...
or result(j,2) = result(j-3,2) ...
or result(j,2) = result(j-4,2) ...
result(j) = data(index+?)
that would be even more complicated.
Thank you very much for the help in advance.