diffn.m

来自「一种新的时频分析方法的matlab源程序。」· M 代码 · 共 45 行

M
45
字号
function d=diffn(x,n)

% The function DIFFN provides a variable window differentiation on data.
%
% Calling sequence-
% d=diffn(x,n)
%
% Example-
%	d=diffn(lod78_p',501);
%
% Input-
%   x   - matrix x(r,c) where r is data length and
%         c is number of components. Data should be
%         in column form, or columns.
%   n   - the full Window Width, an odd number greater then 1
% Output-
%   d   - matrix d(r-n+1,c) that contains the difference 
%         between pairs of values located n-1 points apart:
%         Dx/Dt, where Dt=n-1
 
% Steven R.Long (NASA GSFC/WFF/NASIRF)  Initial

[r,c]=size(x); 		% Get Rows & Columns of Data Input x
							% Length of r is data length
							% Number of c is number of components

hw=(n-1)/2;				% Half-Width of Window
bp=(n+1)/2;    		% Beginning Point, Center of First Window

d=zeros(r-n+1,c);		% Result Data is n-1 less in data length

for j=1:c;				% Do Each Component
  for i=bp:r-hw;		% Reduced Size within c
   ii=i-hw;				% Corresponding Locations in Reduced Matrix
							% Difference Over Window Width
   leftpt=ii;
	rightpt=i+hw;
	d(ii,j)=x(rightpt,j)-x(leftpt,j); % Difference of End.Pts,
													% rightpt is later in t
  end;					% Difference Over Window Placed in Center
end;						% Calculated Over All Columns

return;

⌨️ 快捷键说明

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