Filter löschen
Filter löschen

how to delete same data

3 Ansichten (letzte 30 Tage)
Innosens
Innosens am 31 Okt. 2012
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 Kommentare
Walter Roberson
Walter Roberson am 31 Okt. 2012
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 am 31 Okt. 2012
walter Roberson one row is removed example
5 0 25 99 1009
5 0 25 100 1009
became
5 0 25 100 1009

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 31 Okt. 2012
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],:);

Weitere Antworten (1)

Walter Roberson
Walter Roberson am 31 Okt. 2012
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 Kommentar
Innosens
Innosens am 31 Okt. 2012
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?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Variables finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by