📄 dfirwin.m
字号:
function hwn = dfirwin(ty,n,fc,samp,fp,fs,wind,p1)
% Impulse response for window-based design
% This will be used to find and plot the spectrum (see fir_plot.m)
% HN = firwhb(TY,N,FC,WIND,P1)
% TY = 'lp', 'bp', 'bs', 'hp'
% N = filter length
% FC=cutoff frequency (for LP and HP)
% FC=[FC, F0] for BP and Bs (where F0 is center frequency
% WIND = window name in quotes (DEFAULT: 'hamming')
% P1 = parameter for Kaiser and Dolph(Cbeby) window
% NOTE: For halfband design, N must be odd.
% For window design, N ust be odd if ty=BS or window=dolph(cheby)
%
% HWN returns coefficients of the LP prototype filter
% Author: Ashok Ambardar <akambard@mtu.edu>
% Date: 2/2/96 11:32AM
% Copyright (c) 1997 by Prentice-Hall, Inc.
[wp,ws,w3]=dfirlpp(ty,2*pi*fp,2*pi*fs,samp);
wc = 2*pi*fc;
n0 = fix(n/2);
n1 = 1:n0;
hwin = winwind(wind,n,p1);
if rem(n,2) == 1,
h = sin(wc*n1)./n1/pi;
h = [fliplr(h) wc/pi h];
else
h = sin(wc*(n1-.5))./(n1-.5)/pi;
h = [fliplr(h) h];
end
hw = h.*hwin;
if ty == 1, % lowpass
hwn = hw;
end
if rem(n,2) == 1,
nn = -n0:n0;
else
nn = [-n0+.5:-.5 .5:n0-.5];
end
if ty == 2, % highpass
hwn = hw.*((-1).^nn);
end
if ty == 3, % bandpass
hwn = 2*cos(nn*w3).*hw;
end
if ty == 4, % bandstop
hwn = -2*cos(nn*w3).*hw;
hwn(n0+1) = 1+hwn(n0+1);
end
hwn = hwn.*(abs(hwn)>10*eps);
%hwn = hwn/sum(hwn);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -