I had a question and got an answer yesterday about removing doubling rows in a matrix, and I can't figure out why it omits certain rows in a matrix.
With a matrix:
tmp2 =
0 1.0000
0.1000 1.0000
0.2000 1.0000
0.3000 1.0000
0.3000 2.0000
0.4000 2.0000
0.5000 2.0000
0.6000 2.0000
0.7000 2.0000
0.7000 3.0000
0.8000 3.0000
0.9000 3.0000
1.0000 3.0000
1.1000 3.0000
1.2000 3.0000
I need to remove the rows:
0.3000 2.0000
0.7000 3.0000
I tried to do it with
[~,b] = unique(tmp2(:,1));
tmp2(b,:)
I wrote something on my own
tmp3 = [];
for i=1:numel(tmp2(:,1))-1
if tmp2(i,1) == tmp3
tmp2(i,:) = [];
end
tmp3 = tmp2(i,1);
end
But all of the methods seem to omit the first row to remove... Please help, as I already spent some hours trying to fix it myself (I suck at programming...) and nothings seems to work. The matrix is an example, but generally if two rows have the same value in the first column I have to remove the second one