Remove values from column that are close in value to each other

5 ビュー (過去 30 日間)
Austin Bollinger
Austin Bollinger 2021 年 12 月 20 日
回答済み: David Hill 2021 年 12 月 20 日
I have a column of values:
43
90
91
128
191
192
I would like to remove the values that are close to each other in value, but keep the highest value.
I would want the column to look like this:
43
91
128
192
Is this possible or should I rethink my way of doing this?

採用された回答

Matt J
Matt J 2021 年 12 月 20 日
編集済み: Matt J 2021 年 12 月 20 日
One possibility:
x=[43
90
91
128
191
192];
[~,~,G]=uniquetol(x,10,'DataScale',1);
splitapply(@max,x,G)
ans = 4×1
43 91 128 192

その他の回答 (1 件)

David Hill
David Hill 2021 年 12 月 20 日
x=sort(x);%make sure x is sorted
x(diff(x)<2)=[];

カテゴリ

Help Center および File ExchangeNumeric Types についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by