?? fir digital filter(with chebyshev algorithm).m
字號:
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 + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -