140 likes | 303 Views
Signals and Systems (Lab) Resource Person : Hafiz Muhammad Ijaz
E N D
Signals and Systems (Lab) Resource Person : Hafiz Muhammad Ijaz COMSATS Institute of Information Technology Lahore Campus www.powerpointpresentationon.com
EXPERIMENT # 9 MATLAB implementation of Analog and Digital Filters
In This Lab… • What are Filters and their Types? • What is meant by Analog Filters? • How to implement RC Low Pass Filter using MATLAB • How to implement RC High Pass Filter using MATLAB • What are Digital Filters and their types? • How to design FIR Low Pass Filter? • How to design FIR High Pass Filter? • How to design FIR Band Pass Filter? • MATLAB implementation of Butterworth IIR Low Pass Filter?
Filters and their Types • Types of Filters • Analog Filters • Digital Filters
RC Low Pass Filter with Cutoff 200Hz R=1000; C=0.00001/2; w=0:0.01:5000; a=sqrt(1+(w*R*C).^2); b=1./a; plot(w,abs(b)) title('Low Pass Filter') xlabel('Frequency') ylabel('Magnitude')
RC High Pass Filter with Cutoff 200Hz R=1000; C=0.00001/2; w=0:0.01:5000; a=sqrt(1+(w*R*C).^2); b=(w*R*C)./a; plot(w,abs(b)) title('High Pass Filter') xlabel('Frequency') ylabel('Magnitude')
Comparison of Low Pass & High Pass R=1000; C=0.00001/2; 1/(R*C) w=0:0.01:5000; a=sqrt(1+(w*R*C).^2); b=1./a; subplot(211) plot(w,abs(b)) title('Low Pass Filter') xlabel('Frequency') ylabel('Magnitude') b=(w*R*C)./a; subplot(212) plot(w,abs(b)) title('High Pass Filter') xlabel('Frequency') ylabel('Magnitude') ylim([0 1.1])
Digital Filters and its types IIR Filters FIR Filters • difficult to control, no particular • techniques available can be unstable, • less • derived from analog filters • linear phase always possible • always stable, • more • no analog history • Phase • Stability • Order • History
FIR Low Pass Filter with Cutoff 1200Hz fs=8000; % sampling frequency n=50; % order of the filter w=1200/ (fs/2); b=fir1(n,w,'low'); % Zeros of the filter freqz(b,1,128,8000 figure(2) [h,w]=freqz(b,1,128,8000); plot(w,abs(h));
FIR High Pass Filter with Cutoff 1200Hz fs=8000; n=50; w=1200/ (fs/2); b=fir1(n,w,'high'); freqz(b,1,128,8000); figure(2) [h,w]=freqz(b,1,128,8000) plot(w,abs(h));
FIR Band Pass Filter with Pass Band 1200--1800Hz fs=8000; n=40; b=fir1(n,[1200/4000 1800/4000],'bandpass'); freqz(b,1,128,8000) figure(2) [h,w]=freqz(b,1,128,8000); plot(w,abs(h));
Butterworth IIR Low Pass Filter fs=8000; [n,w]=buttord(1200/4000,1500/4000,1,50); % finding the order of the filter [b,a]=butter(n,w); % finding zeros and poles for filter figure(1) freqz(b,a,512,8000); figure(2) [h,q] = freqz(b,a,512,8000); plot(q,abs(h));
Summary • Filters and their basic Types • Analog Filters • MATLAB implementation of RC Low Pass and High Pass Filters • Digital Filters and their types • MATLAB implementation of FIR Low Pass, High Pass and Band Pass Filter • MATLAB implementation of Butterworth IIR Low Pass Filter