Removing outliers from data

4 ビュー (過去 30 日間)
AU
AU 2019 年 5 月 31 日
編集済み: Adam 2019 年 5 月 31 日
How can I remove outliers of a vector where an outlier is defined as a point more than three standard deviations from the mean of the data in matlab 2R2017b? I also want to remove outliers using a 10 day moving average or a smoothed average.

採用された回答

Adam
Adam 2019 年 5 月 31 日
編集済み: Adam 2019 年 5 月 31 日
threshold = 3 * std( data );
validRange = mean( data ) + [-1 1] * threshold;
dataWithoutOutliers = data( data >= validRange(1) & data <= validRange(2) );
should do the first bit, though that is typed off the top of my head, not tested.
doc movmean
should help with a moving average if you are using R2016a or later.
  2 件のコメント
AU
AU 2019 年 5 月 31 日
Thank you for the answer Adam. The last line gives me the error: Operands to the || and && operators must be convertible to logical scalar values. How can I solve it?
Adam
Adam 2019 年 5 月 31 日
編集済み: Adam 2019 年 5 月 31 日
Ah, yes. I've corrected the answer now, using just a simple & to AND together non-scalar arrays.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by