Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
PRACTICALAPPLICATIONOFFIRFILTERS
PRACTICALAPPLICATIONOFFIRFILTERS
Contents
Clearingthecommandwindow,workspaceandclosinganyopennedfigurefiles
LoadingtheCHIRPNoiseandplayingit
HighPassFiltering
PlotingtheOriginalSoundvsHighPassFilteredSound
LowPassFiltering
PlotingtheOriginalSoundvsLowPassFilteredSound
Clearingthecommandwindow,workspaceandclosinganyopennedfigurefiles
clc;clearall;closeall;
LoadingtheCHIRPNoiseandplayingit
loadchirp
%Thereshouldbe2variablesin
%thecommandwindow.
%y=ActualSound
%Fs=SamplingRateofthesound
%Ifyouwanttoplaythesoundusethecommand
%sound(y,Fs)
sound(y,Fs);%playingthesound
HighPassFiltering
fc=0.48;%CutoffFrequencyofthehighpassfilterin/piradians
N=34;%OrderofHighPassFilter
bhi=fir1(N,fc,'high',chebwin(N+1,30));%HighPassFIRFilterofOrderN
freqz(bhi,1)%ObtainingtheFrequencyResponseofHighFilter
outhi=filter(bhi,1,y);%ObtainingtheHighPassFilteredOutput
sound(outhi,Fs);%playingtheHighpassfilteredsound
file:///E:/LABENGINEER%20AmmarMalik/SU15_DSPLabs/html/FIR_Example2.html
1/5
04/07/2015
PRACTICALAPPLICATIONOFFIRFILTERS
Thereisalmostnochangeinsound,becauseallthehighfrequencieshavebeenallowedtopass.
PlotingtheOriginalSoundvsHighPassFilteredSound
figure;
t=(0:length(y)1)/Fs;%Durationofthesoundinseconds
subplot(2,1,1)
plot(t,y)%OriginalSound
title('OriginalSignal')
subplot(2,1,2)
plot(t,outhi)%HighPassFilteredSound
title('HighpassFilteredSignal')
xlabel('Time(s)')
file:///E:/LABENGINEER%20AmmarMalik/SU15_DSPLabs/html/FIR_Example2.html
2/5
04/07/2015
PRACTICALAPPLICATIONOFFIRFILTERS
LowPassFiltering
fc=0.48;%CutoffFrequencyoftheLowpassfilterin/piradians
N=34;%OrderofLowPassFilter
figure;
blo=fir1(N,fc,chebwin(N+1,30));%LowPassFIRFilterofOrderN
freqz(blo,1)%ObtainingtheFrequencyResponseofHighFilter
outlo=filter(blo,1,y);%ObtainingtheLowPassFilteredOutput
sound(outlo,Fs);%playingtheLowpassfilteredsound
file:///E:/LABENGINEER%20AmmarMalik/SU15_DSPLabs/html/FIR_Example2.html
3/5
04/07/2015
PRACTICALAPPLICATIONOFFIRFILTERS
Thereisalmostnosoundtobeheardthistime,becauseallthehighfrequencieshavebeenblockedandonlylow
frequenciesareallowedtopass.
PlotingtheOriginalSoundvsLowPassFilteredSound
figure;
subplot(2,1,1)
plot(t,y)%OriginalSound
title('OriginalSignal')
subplot(2,1,2)
plot(t,outlo)%LowPassFilteredSound
title('LowpassFilteredSignal')
xlabel('Time(s)')
axis([01.811])%axiscommandusedtoviewbothsignalsusingsamescale
file:///E:/LABENGINEER%20AmmarMalik/SU15_DSPLabs/html/FIR_Example2.html
4/5
04/07/2015
PRACTICALAPPLICATIONOFFIRFILTERS
NOTE:Noneedtodefinetime't'againforlowpassfiltering,asthetimedurationwillbesame.
PublishedwithMATLABR2013a
file:///E:/LABENGINEER%20AmmarMalik/SU15_DSPLabs/html/FIR_Example2.html
5/5