Remove successive rows from a table where a specific column value is duplicated

2 ビュー (過去 30 日間)
Hi all ,
I HAVE this table A :
time lon lat site
12:45 23.23234 45.2324 ZRY122
13:45 12.21342 34.456 ZRY101
11:2345 1234.24 12.5555 ZRY122
22:34 23.4343 2.34566 ZRY122
22:14 23.4303 2.34596 ZRY555
i want to remove consecutive(successive) rows where site column is same, for example , i want to get this :
time lon lat site
12:45 23.23234 45.2324 ZRY122
13:45 12.21342 34.456 ZRY101
11:2345 1234.24 12.5555 ZRY122
22:14 23.4303 2.34596 ZRY555
UNIQUE here will not work because it will keep only one instance of the column site !!
Thanks

採用された回答

Matt J
Matt J 2021 年 1 月 24 日
編集済み: Matt J 2021 年 1 月 24 日
idx = diff([inf;findgroups(A.site)])~=0;
A = A(idx,:)
  2 件のコメント
Adam Danz
Adam Danz 2021 年 1 月 24 日
編集済み: Adam Danz 2021 年 1 月 24 日
Was about to suggest something very similar,
G=findgroups(A.site);
rmIdx = [1;diff(G)]==0;
A(rmIdx,:) = [];
Tareq Rahmani
Tareq Rahmani 2021 年 1 月 25 日
Thanks very much Adam and Matt.
Excellent

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Exploration についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by