Remove row if its value is not different enough from the value in the row above it.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Aleya Marzuki
am 16 Aug. 2022
Kommentiert: Aleya Marzuki
am 16 Aug. 2022
I have the table above. If the difference between latencies in one row is not much different from the latencies in the second row (difference <= 100), I would like to have the second row removed. To illustrate, row 305 would be removed in the table above because the difference in latencies between it and row 304 is less than 100. Would really appreciate suggestions on how best to do this, thank you!
0 Kommentare
Akzeptierte Antwort
Chunru
am 16 Aug. 2022
% Generate data
latency = [1000 1010 1020 1800]';
dur = zeros(size(latency));
type = ones(size(latency)) * 256;
T = table(latency, dur, type)
% diff
ldiff = diff(T.latency);
idx = find(ldiff <= 100) + 1;
T(idx, :) =[];
T
Weitere Antworten (1)
Simon Chan
am 16 Aug. 2022
Let A be your matrix, try the following:
threshold = 100;
A([false;(diff(A(:,1))<=threshold)],:)=[];
Siehe auch
Kategorien
Mehr zu Logical 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!