Removing Outbound (out of range) data from an array

7 ビュー (過去 30 日間)
Farbod Tavakkoli
Farbod Tavakkoli 2019 年 11 月 7 日
コメント済み: Farbod Tavakkoli 2019 年 11 月 7 日
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,

採用された回答

Fabio Freschi
Fabio Freschi 2019 年 11 月 7 日
% 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);
  1 件のコメント
Farbod Tavakkoli
Farbod Tavakkoli 2019 年 11 月 7 日
Thank you so much!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDatabase Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by