LAB 2 - Lab Report of 2nd lab PDF

Title LAB 2 - Lab Report of 2nd lab
Author Mahnoor Athar
Course Principles of Communication Systems
Institution COMSATS University Islamabad
Pages 10
File Size 721 KB
File Type PDF
Total Downloads 81
Total Views 147

Summary

Lab Report of 2nd lab...


Description

Lab#02 Filter Designing in MATLAB: Low Pass, High Pass, BandPass and Band-Stop In-Lab: Task 1: Design the low pass filter for the cut-off frequency 250Hz. Plot the filter response. MATLAB Code:

Fs = 1000; % Sampling frequency T = 1/Fs; % Sample time L = Fs; % Length of signal t = (0:L-1)*T; % Time vector x = 0.7*sin(2*pi*300*t)+0.2*sin(2*pi*50*t) ; figure(); plot(t,x) title('Signal') xlabel('time (milliseconds)') NFFT = 2^nextpow2(L); X = fft(x,NFFT)/L; f = Fs/2*linspace(0,1,NFFT/2+1); % figure(); % Plot single-sided amplitude spectrum. plot(f,abs(X(1:NFFT/2+1))) title('Single-Sided Amplitude Spectrum of x(t)') xlabel('Frequency (Hz)') ylabel('|X(f)|') d = fdesign.lowpass( 200, 250 ,1,100, Fs); Hd = design(d,'equiripple'); fvtool(Hd); % Filter Visualization Tool LP_Filterd_Output = filter(Hd,x); % filter function convolves plot(LP_Filterd_Output); NFFT = 2^nextpow2(L); % Next power of 2 from length of x LP_Filtered_Freq = fft(LP_Filterd_Output,NFFT)/L; f = Fs/2*linspace(0,1,NFFT/2+1); figure(); % Plot single-sided amplitude spectrum of HPF. plot(f,abs(LP_Filtered_Freq(1:NFFT/2+1))) title('Single-Sided Amplitude Spectrum of LP-FilteredOutput') xlabel('Frequency (Hz)') ylabel('|LP_Filtered-Freq-Amplitude|')

Filter Response:

Task 2: Design the high pass filter for the cut-off frequency 170Hz. Plot the filter response. MATLAB Code: Fs = 1000; % Sampling frequency T = 1/Fs; % Sample time L = Fs; % Length of signal t = (0:L-1)*T; % Time vector x = 0.7*sin(2*pi*300*t)+0.2*sin(2*pi*50*t) ; figure(); plot(t,x) title('Signal') xlabel('time (milliseconds)') NFFT = 2^nextpow2(L); X = fft(x,NFFT)/L; f = Fs/2*linspace(0,1,NFFT/2+1); % figure(); % Plot single-sided amplitude spectrum. plot(f,abs(X(1:NFFT/2+1))) title('Single-Sided Amplitude Spectrum of x(t)') xlabel('Frequency (Hz)') ylabel('|X(f)|') d = fdesign.highpass( 100, 170,100,1, Fs); Hd = design(d,'equiripple'); fvtool(Hd); % Filter Visualization Tool HP_Filterd_Output = filter(Hd,x); % filter function convolves plot(HP_Filterd_Output); NFFT = 2^nextpow2(L); % Next power of 2 from length of x HP_Filtered_Freq = fft(HP_Filterd_Output,NFFT)/L; f = Fs/2*linspace(0,1,NFFT/2+1); figure(); % Plot single-sided amplitude spectrum of HPF. plot(f,abs(HP_Filtered_Freq(1:NFFT/2+1))) title('Single-Sided Amplitude Spectrum of HP-FilteredOutput') xlabel('Frequency (Hz)') ylabel('|HP_Filtered-Freq-Amplitude|')

Filter Response:

Task 3: Design the Band-Pass filter for the frequency range 250-550Hz. Plot the filter response. MATLAB Code: % Sampling frequency Fs = 2000; T = 1/Fs; % Sample time L = Fs; % Length of signal t = (0:L-1)*T; % Time vector x = 0.7*sin(2*pi*300*t)+0.2*sin(2*pi*50*t) ; figure(); plot(t,x) title('Signal') xlabel('time (milliseconds)') NFFT = 2^nextpow2(L); X = fft(x,NFFT)/L; f = Fs/2*linspace(0,1,NFFT/2+1); figure(); % Plot single-sided amplitude spectrum. plot(f,abs(X(1:NFFT/2+1))) title('Single-Sided Amplitude Spectrum of x(t)') xlabel('Frequency (Hz)') ylabel('|X(f)|') d = fdesign.bandpass(200,250,550,600,100,1,100,Fs); Hd = design(d,'equiripple'); fvtool(Hd); % Filter Visualization Tool BP_Filterd_Output = filter(Hd,x); % filter function convolves plot(BP_Filterd_Output); NFFT = 2^nextpow2(L); % Next power of 2 from length of x BP_Filtered_Freq = fft(BP_Filterd_Output,NFFT)/L; f = Fs/2*linspace(0,1,NFFT/2+1); figure(); % Plot single-sided amplitude spectrum of HPF. plot(f,abs(BP_Filtered_Freq(1:NFFT/2+1))) title('Single-Sided Amplitude Spectrum of BP-FilteredOutput') xlabel('Frequency (Hz)') ylabel('|BP_Filtered-Freq-Amplitude|')

Filtered Response:

Task 4: Design the Band-Stop filter for the frequency range, 250-550Hz. Plot the filter response. MATLAB Code: Fs = 2000; % Sampling frequency T = 1/Fs; % Sample time L = Fs; % Length of signal t = (0:L-1)*T; % Time vector x = 0.7*sin(2*pi*300*t)+0.2*sin(2*pi*50*t) ; figure(); plot(t,x) title('Signal') xlabel('time (milliseconds)') NFFT = 2^nextpow2(L); X = fft(x,NFFT)/L; f = Fs/2*linspace(0,1,NFFT/2+1); figure(); % Plot single-sided amplitude spectrum. plot(f,abs(X(1:NFFT/2+1))) title('Single-Sided Amplitude Spectrum of x(t)') xlabel('Frequency (Hz)') ylabel('|X(f)|') d = fdesign.bandstop(250,300,500,550,1,100,1,Fs); Hd = design(d,'equiripple'); fvtool(Hd); % Filter Visualization Tool BS_Filterd_Output = filter(Hd,x); % filter function convolves plot(BS_Filterd_Output); NFFT = 2^nextpow2(L); % Next power of 2 from length of x BS_Filtered_Freq = fft(BS_Filterd_Output,NFFT)/L; f = Fs/2*linspace(0,1,NFFT/2+1); figure(); % Plot single-sided amplitude spectrum of HPF. plot(f,abs(BS_Filtered_Freq(1:NFFT/2+1))) title('Single-Sided Amplitude Spectrum of BS-FilteredOutput') xlabel('Frequency (Hz)') ylabel('|BS_Filtered-Freq-Amplitude|')

Filtered Response:

Task 5: Design and analyze the above filters (task 1-4) using FDA-Tool. 1) Lowpass Filter:

2) Highpass Filter: 3) Bandpass Filter:

4) Bandstop Filter:

Critical Analysis: In this lab we designed the four major types of filters that are lowpass, highpass, bandpass and bandstop filters. We used functions such as fdesign, design, fvtool, filter to fully demonstrate the functionality of the filter. Also a filter with standard specifications can also be designed using fdatool (filter design and analysis) command. This method of designing filters is effective when general/standard specifications are known....


Similar Free PDFs