matlab 剪毛刺,MATLAB消除曲线毛刺Outlier Detection and Removal [hampel]

该博客介绍了MATLAB中用于消除曲线毛刺和异常值的Hampel滤波器函数,包括标准和自适应两种模式。通过示例展示了如何使用该函数进行数据平滑处理,以及如何检测和替换异常值。
摘要由CSDN通过智能技术生成

MATLAB消除曲线毛刺Outlier Detection and Removal [hampel]

function [YY, I, Y0, LB, UB, ADX, NO]=hampel(X, Y, DX, T, varargin)%HAMPEL Hampel Filter.%HAMPEL(X,Y,DX,T,varargin) returns the Hampel filtered values of the% elements in Y. It was developed to detect outliers ina time series,% but it can also be used asan alternative to the standard median%filter.%

%References% Chapters 1.4.2, 3.2.2 and 4.3.4 inMining Imperfect Data: Dealing with%Contamination and Incomplete Records by Ronald K. Pearson.%

%Acknowledgements% I would like to thank Ronald K. Pearson forthe introduction to moving%window filters. Please visit his blog at:% http://exploringdatablog.blogspot.com/2012/01/moving-window-filters-and

% -pracma.html%

%X,Y are row or column vectors with an equal number of elements.% The elements inY should be Gaussian distributed.%

% Input DX,T,varargin must not contain NaN values!

%

%DX,T are optional scalar values.% DX isa scalar which defines the half width of the filter window.% It is required that DX > 0and DX should be dimensionally equivalent to% the values inX.% T is a scalar which defines the threshold value used inthe equation% |Y - Y0| > T*S0.%

% Standard Parameters forDX and T:% DX = 3*median(X(2:end)-X(1:end-1));% T = 3;%

% varargin covers addtional optional input. The optional input must be in

% the form of 'PropertyName', PropertyValue.%Supported PropertyNames:% 'standard': Use the standard Hampel filter.% 'adaptive': Use an experimental adaptive Hampel filter. Explained under% Revision 1details below.%

%Supported PropertyValues: Scalar value which defines the tolerance of% the adaptive filter. In the case of standard Hampel filter thisvalue% isignored.%

%Output YY,I,Y0,LB,UB,ADX are column vectors containing Hampel filtered%values of Y, a logical index of the replaced values, nominal data,%lower and upper bounds on the Hampel filter and the relative half size%of the local window, respectively.%

% NO isa scalar that specifies the Number of Outliers detected.%

%Examples% 1. Hampel filter removal of outliers% X = 1:1000; %Pseudo Time% Y = 5000 + randn(1000, 1); %Pseudo Data% Outliers = randi(1000, 10, 1); %Index of Outliers% Y(Outliers) = Y(Outliers) + randi(1000, 10, 1); %Pseudo

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值