how to delete same data

i have data
12 0 26 94 1011
12 30 26 100 1011
1 0 26 94 1011
1 30 26 94 1011
*2 0 26 95 1011
2 0 26 94 1011*
2 30 26 100 1010
3 0 26 100 1010
3 30 26 100 1010
4 0 26 94 1009
4 30 25 100 1009
*5 0 25 99 1009
5 0 25 100 1009*
5 30 26 100 1009
i want to delete same data , so the data became that.
12 0 26 94 1011
12 30 26 100 1011
1 0 26 94 1011
1 30 26 94 1011
2 0 26 95 1011
2 30 26 100 1010
3 0 26 100 1010
3 30 26 100 1010
4 0 26 94 1009
4 30 25 100 1009
5 0 25 99 1009
5 30 26 100 1009
i have tired , using unique.. thanks

6 件のコメント

Innosens
Innosens 2012 年 10 月 31 日
the reference is in column 2 , pattern formed is 0, 30. but in column 2 row 5 and 6 is same, row 13 and row 14 is same
2 0 26 95 1011
2 0 26 94 1011
5 0 25 99 1009
5 0 25 100 1009
Walter Roberson
Walter Roberson 2012 年 10 月 31 日
You only have two distinct values in column 2, so deleting all the duplicates based on those values alone would give you just two rows of results.
Are you looking for unique values based on the combination of column 1 and column 2? If so, then when you find a duplicate, should the first of them be deleted, or the one that has the maximum in one of the other columns, or some other criteria ?
Innosens
Innosens 2012 年 10 月 31 日
only column 2, because pattern data like that. this only sample data i want to make easy program because my data is large
12 0 26 94 1011
12 30 26 100 1011
1 0 26 94 1011
1 30 26 94 1011
2 0 26 95 1011
2 30 26 100 1010
3 0 26 100 1010
3 30 26 100 1010
4 0 26 94 1009
4 30 25 100 1009
5 0 25 99 1009
5 30 26 100 1009
any idea?
Jonathan Epperl
Jonathan Epperl 2012 年 10 月 31 日
編集済み: Jonathan Epperl 2012 年 10 月 31 日
I don't get it either. You had
5 0 25 99 1009
5 0 25 100 1009
and you deleted the 2nd row, even though the data in column 4 are 99 and 100, respectively. So why is that? Please just state clearly according to which criterion you want to delete rows, or we cannot help you.
Walter Roberson
Walter Roberson 2012 年 10 月 31 日
Is the rule that if you have two of the same column 2 value in a row, that you should delete the first of them, no matter what the values are in the other columns?
Innosens
Innosens 2012 年 10 月 31 日
walter Roberson one row is removed example
5 0 25 99 1009
5 0 25 100 1009
became
5 0 25 100 1009

サインインしてコメントする。

 採用された回答

Andrei Bobrov
Andrei Bobrov 2012 年 10 月 31 日

0 投票

a = [ 12 0 26 94 1011
12 30 26 100 1011
1 0 26 94 1011
1 30 26 94 1011
2 0 26 95 1011
2 0 26 94 1011
2 30 26 100 1010
3 0 26 100 1010
3 30 26 100 1010
4 0 26 94 1009
4 30 25 100 1009
5 0 25 99 1009
5 0 25 100 1009
5 30 26 100 1009];
out = a([true;diff(a(:,2)) ~= 0],:);

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 10 月 31 日

0 投票

There are no duplicate rows in your data; each one has something unique about it. How should it be determined which one to delete? If certain columns are to be ignored in the matching, then should the first of them be deleted, or the one with the maximum in the column not used for matching, or ... ?

1 件のコメント

Innosens
Innosens 2012 年 10 月 31 日
only column 2, because pattern data like that. this only sample data i want to make easy program because my data is large
12 0 26 94 1011
12 30 26 100 1011
1 0 26 94 1011
1 30 26 94 1011
2 0 26 95 1011
2 30 26 100 1010
3 0 26 100 1010
3 30 26 100 1010
4 0 26 94 1009
4 30 25 100 1009
5 0 25 99 1009
5 30 26 100 1009
any idea?

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by