How can i delete repeated rows?

2 次查看(过去 30 天)
I have a matrix A as follows
A = 1,1,2,3,4
2,1,2,3,4
I'd like to consider that the two rows are identical as the firs column only describes the index, so the output should like
A = 1,1,2,3,4
or
A= 2,1,2,3,4
when I make use of unique(A,'rows') it doesn't consider the two rows are identical
Any help, please.

采纳的回答

Guillaume
Guillaume 2016-8-3
编辑:Guillaume 2016-8-3
Use the second return value of unique:
[~, rowstokeep] = unique(A(:, 2:end), 'rows');
newA = A(rowstokeep, :)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by