MATLAB: Matrix

matrix

how I can remove rows from matrix each elements in these rows are equals m=[1 2 3;1 1 1;4 5 8;4 5 8;1 1 1;1 1 1;1 1 1;1 1 1;1 1 1;1 1 1;1 1 1;1 1 1;4 5 8;7 8 5; 47 9 5;7 8 5;5 322 5;7 8 55];

Best Answer

m=[1 2 3;1 1 1;4 5 8;4 5 8;1 1 1;1 1 1;1 1 1;1 1 1;1 1 1;1 1 1;1 1 1;1 1 1;4 5 8;7 8 5; 47 9 5;7 8 5;5 322 5;7 8 55];
variant 1
[a b n] = unique(m,'rows','first');
[id id] = sort(b);
out1 = a(id,:);
variant 2
[a b n] = unique(m,'rows','first');
[id id] = sort(b);
t = accumarray(n,ones(numel(n),1)) == 1;
a2 = a(id,:);
out2 = a2(t(id),:);