对于一个向量,使用unique去重后会自动排序,为了保持原顺序:
A = [5,1,8,5,2,8,3,9,6,1];
[i,j] = unique(A,'first');
B = A(sort(j));
----------------------------------------
B = [5,1,8,2,3,9,6]
2023-10-03 10:58:40
对于一个向量,使用unique去重后会自动排序,为了保持原顺序:
A = [5,1,8,5,2,8,3,9,6,1];
[i,j] = unique(A,'first');
B = A(sort(j));
----------------------------------------
B = [5,1,8,2,3,9,6]