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

📄 deriv.m

📁 英文书《Digital Signal Processing with Examples in MATLAB》附带的MATLAB实例
💻 M
字号:
function dx=deriv(x,N,T,vc)
% dx=deriv(x,N,T,vc)
%
% dx is the fir-differentiated verson of waveform vector x.
% N  =length of differentiator - see text, p.126ff.
%     N must be odd and at least 5. If even, N is increased by 1.
% T  =time step between elements of x.
% vc =cutoff frequency in Hz-s. May be omitted.
%     If vc is omitted, vc is set to 0.5 Hz-s.
%
[nr,nc]=size(x);
% Check for errors etc.
if N<5,
    error('N must be at least 5.');
elseif rem(N,2)==0,
    N=N+1;
    fprintf('Warning: N is increased to%4.0f\',N);
elseif nr~=1 & nc~=1,
    error('x must be a vector.');
end
if nargin<4,
    vc=0.5;
end

% Derive the weights.
L=(N-1)/2;
h=zeros(N,1);
k=0:L-1;
costerm=(2*pi*vc/T)*cos((k-L)*2*pi*vc)./((k-L)*pi);
sinterm=sin(2*pi*(k-L)*vc)./((k-L).^2*pi*T);
h(1:L)=costerm-sinterm;
h(N:-1:L+2)=-h(1:L);

% Apply the hamming window and filter.
w=window(N,'hamming');
dx=filter(h.*w',1,x);

⌨️ 快捷键说明

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