Removing Outbound (out of range) data from an array
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Farbod Tavakkoli
am 7 Nov. 2019
Kommentiert: Farbod Tavakkoli
am 7 Nov. 2019
I have an array which includes 3 million data points. The average of this array in equal to 10 but the variance is too much. However, I tried to use moving average to decreace the variance but I'm looking for a way to remove the out of range data from the array before taking moving average. For instance, in my array, most of the numbers of between 5 and 15 but also I have some numbers that are about 200000. How can I delete unwanted data points from my array?. Is there any function for that?. Basically, I know the logical range of the numbers in the array, and I just want the numbers in that range.
I appreciate your kind help in advance,
0 Kommentare
Akzeptierte Antwort
Fabio Freschi
am 7 Nov. 2019
% dimension
N = 1000000;
% data in (0,1)
x = rand(N,1);
% threshold
xMin = 0.25;
xMax = 0.75;
% remove data out of the range
x(x < xMin |x > xMax) = [];
% or (this is faster for large datasets)
xKept = x(x < xMax);
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Database Toolbox 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!