⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smoothn.m

📁 这是一个关于hht变换很有用的工具箱
💻 M
字号:
function d=smoothn(x,n)
 
% The function SMOOTHN provides a horizontal variable window smoothing of 2-D data.
% Data x(r,c) that requires smoothing should be in column form.
%
% Calling sequence-
% d=smoothn(x,n)
%
% Input-
%	x	- 2-D matrix of data x(r,c)
%   n	- an odd number representing the full window width
% Output-
%	d	- 2-D horizontally filtered data d(r,c)
 
% Steven R.Long (NASA GSFC/WFF/NASIRF)	Initial
% J.Marshak (NASA GSFC)				    March 10, 2004 Modified
%				(               corrected the indexing of output)

%----- Get rows & columns of data input x
[r,c]=size(x);

%----- Get half-width of window
hw=(n-1)/2;

%----- Get the beginning point, center of first window			
bp=(n+1)/2;   

%----- Initialize the result data as being equal to the input 
d=x;

%----- Process each component
for j=1:c;
  %----- Smooth the data within requested window
  for i=bp:r-hw;
   % Sum over window width
   sum=0;
   for jj=i-hw:i+hw;
	  sum=sum+x(jj,j);
   end;
   % Average over window placed in center
   d(i,j)=sum/n;
  end;
  %----- Smooth the data outside requested window
  %----- by reducing the window length, but keeping it as an odd number
  % Reduce the window by 2
  nw=n-2;
  nhw=(nw-1)/2;
  nnb=bp;
  nne=r-hw;
  % Keep smoothing until window is at least 3 points
  while (nw > 1)
    nnb=nnb-1;
    sum=0;
    for jj=nnb-nhw:nnb+nhw
        sum=sum+x(jj,j);
    end;
    d(nnb,j)=sum/nw;
    nne=nne+1;
    sum=0;
    for jj=nne-nhw:nne+nhw
        sum=sum+x(jj,j);
    end;
    d(nne,j)=sum/nw;
    nw=nw-2;
    nhw=(nw-1)/2;
  end
end;

return;

⌨️ 快捷键说明

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