How to remove duplicate observations in a matrix after sorting it?

I have a matrix FINAL=[1001,4,5,2015;1002,4,5,2015;1001,4,10,2014;1003,4,10,2014]
I want to sort this matrix by col 1, col 4, col 2, col 3 (i.e. organize column 1 by date)
Then I want to keep only the first row of a unique value of column 1
Any advice?

Answers (1)

FINAL=[1001,4,5,2015;1002,4,5,2015;1001,4,10,2014;1003,4,10,2014]
X = sortrows(FINAL,[1 4 2 3]) % not sure what you want here ...
[~,i] = unique(X(:,1))
OUT = X(i,:)

Categories

Asked:

TA
on 14 Apr 2016

Answered:

on 14 Apr 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!