close all;
clear all;
clc;
f1=1900;
f2=5100;
f3=7000;
Fs=20000;
N=1000;
n=0:1/Fs
N-1)/Fs;
y=sin(2*pi*f1.*n)+cos(2*pi*f2.*n)+sin(2*pi*f3.*n);
plot(n,y)
xlabel('Time /sec');
ylabel('Amplitude volts');
title('the signal in Time Domain before filter');
Y=fft(y,N);
F=(0:N-1)*Fs/N;
figure
plot(F,abs(Y))%1
xlabel('Frequency /Hz');
ylabel('Amplitude volts');
title('the signal in Frequency Domain before filter');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
%
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
f1=1900;%this signal frequency will be passed in the filter
f2=5100;%this signal frequency will be filtered in the filter
f3=7000;%this signal frequency will be filtered in the filter
Fs=20000;% the sample frequency
%w1/pi=0.19;
w1=2*pi*f1/Fs %normalization in digital frequency domain
wp=0.2*pi;
ws=0.25*pi;
wc=(wp+ws)/2;
width=ws-wp;
order=ceil(6.6*pi/width)+1;
window=hamming(order);
alpha=(order-1)/2;
n=[0:1
order-1)];
m=n-alpha+eps;
hd=sin(wc*m)./(pi*m);
b=fir1(order-1,wc/pi,window);
figure
freqz(b,1,512)
figure
freqz(hd,1,512)
sf1 = filter(b,1,y);
sf2 = filter(hd,1,y);
figure
plot(sf1)
figure
plot(sf2)
figure
plot(F,abs(fft(sf1)))
figure
plot(F,abs(fft(sf2)))
FPGADeveloper 2014-7-19 07:57
用户1645198 2014-7-6 13:21
FPGADeveloper 2011-7-17 10:11
用户468654 2011-7-11 23:21