You can do this using unique :
>> [~,b] = unique(tmp2(:,1)); % indices to unique values in first column of tmp2 >> tmp2(b,:) % values at these rows ans = 0.6000 20.4000 0.7000 20.4000 0.8000 20.4000 0.9000 20.4000 1.0000 19.1000 ...
By default, unique stores the last unique value that it finds, and the result will be sorted. It happens the way you want / have, so you're in luck :)
If this is not what you want / have, you will have to lose some weight. Removing duplicates that preserve order is as follows:
% mess up the order A = randperm(size(tmp2,1)); tmp2 = tmp2(A,:) % use third output of unique [a,b,c] = unique(tmp2(:,1)); % unique values, order preserved tmp2(b(c),:) ans = 1.1000 19.1000 1.2000 19.1000 1.0000 20.4000 0.7000 20.4000 1.0000 20.4000 1.4000 19.1000 0.6000 20.4000 0.9000 20.4000 1.3000 19.1000 0.8000 20.4000 ...
which still saves the last record found. If you want to keep the first record found, use
% unique values, order preserved, keep first occurrence [a,b,c] = unique(tmp2(:,1), 'first');
source share