Compare adjacent elements in a column within array and remove if greater/less than value
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
ljp64
am 12 Jul. 2018
Beantwortet: Walter Roberson
am 12 Jul. 2018
I have a large matrix (15882x9). Data has been imported from excel. I would like to compare adjacent elements within each column, and if the difference is greater than 100 then I want to delete that entire row. (This is an issue with our data collection, unsure why)
I have tried the filloutliers function but this does not quite remove everything I need.
e.g. simple example below... if difference between adjacent elements within column is <15 then delete row.
array = [1 2 3 4; 5 1 20 3; 2 5 4 1]
For column 3, 20 - 3 = 17 so I would like to delete the second row, so now array is:
array = [1 2 3 4; 2 5 4 1]
Thanks for your help :)
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 12 Jul. 2018
threshold = 100;
array( [false; any(diff(array) > threshold,2)], :) = [];
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Spreadsheets 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!