medianfilter.m

来自「hilbert-huang 变换的源码 蛮有用的」· M 代码 · 共 25 行

M
25
字号
function y=medianfilter(x,n) 
  
% The function MEDIANFILTER returns data smoothed by n-point median filter.
%
% Calling sequence-
% y=medianfilter(x,n)
%
% Input-
%	x	- column vector of input data x(n)
% 	n	- number of smoothing points
% Output-
%	y	- column vector of filtered data y(n)
%

%----- Define the smoothing range indexes
lbound = floor(n/2);
rbound = n-lbound-1;

y=x;

%----- Run the filter
for i=lbound+1:length(x)-rbound-1
    y(i)=median(x(i-lbound:i+rbound));
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?