Best Logic for Removing Unwanted Data from the Beginning of an Array
Mostrar comentarios más antiguos
Assume I have an array, something like:
A = [ 50 63 45 43 59 5 5 5 5 5 5 6 6 6 6 5 5 5 5 4 4 4 54 65 43 56 45 5 5 5 4....]
Basically, a long set of data, with some "outlier" values at the start, and long strings of relatively consistent values in the middle, with some more "outliers" thrown into some places in the middle.
My question is, what would be the simplest way to go about removing the "outliers" from the beginning of the array, while leaving the rest of the sequence intact (including the remaining "outliers" in the middle), so it would be:
A = [5 5 5 5 5 5 6 6 6 6 5 5 5 5 4 4 4 54 65 43 56 45 5 5 5 4....]
So far, I've set up a "threshold percentage" of 120% of the lowest value in the array, since I know that will be sufficient to cutoff whatever junk is at the beginning. I'd like to find a simple way to compare against that number in order to determine the cutoff point.
Thanks for any insight you can provide.
Respuestas (1)
Thorsten
el 28 de En. de 2013
It's a one liner:
A(find(diff(find(A > 1.5*min(A))) > 1)+1:end)
Note that I've replaced your 120% criterium with 150% = 6/4 in order to save the 6s.
Categorías
Más información sobre Numbers and Precision en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!