fir digital filter(with chebyshev algorithm).m

来自「Fir滤波器」· M 代码 · 共 36 行

M
36
字号
clear all;
rp=0.25;% Passband ripple
rs=50;  %Stopband ripple
Fs=200; % Sampling frequency
wp1=0.2;%normalized passband frequency
ws1=0.3;%normalized stopband frequency
wp=Fs/2*wp1;%passband frequency
ws=Fs/2*ws1;%stopband frequency
f=[wp ws]; % Cutoff frequencies
a = [1 0]; % Desired amplitudes
% Compute deviations
dev = [(10^(rp/20)-1)/(10^(rp/20)+1)  10^(-rs/20)]; 
[n,fo,ao,W] = firpmord(f,a,dev,Fs);
hn=remez(n+2,fo,ao,W);
hw=fft(hn,512);
w=[0:511]*2/512;
figure(1)%Fig.h(n)
stem(hn),title('h(n)');
figure(2)%Amplitude frequency characteristic 
plot(w,20*log10(abs(hw)),'r');grid on;
axis([0,1,-90,10]);
xlabel('normalized frequency');ylabel('magnitude/dB');
figure(3)%effect of filter
f1=15;f2=40;
dt=1/Fs;t=0:dt:3;
x=sin(2*pi*f1*t)+cos(2*pi*f2*t);
y=fftfilt(hn,x);
subplot(2,1,1),plot(t,x),title('input signal');
subplot(2,1,2),plot(t,y),title('output signal');






⌨️ 快捷键说明

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