Skip to main content
留学咨询

程序代写案例-B 1

By December 22, 2020No Comments

Lab 1: Part B 1 EEE8129 (PART B) –Intelligent Signal Processing Lab Assignment Title: Introduction to Digital Filters Lab Overview This lab consists of four Tasks. Objectives The objectives of this lab are as follows: i. Gain familiarity with Digital Filters; ii. Understand the transfer function of Digital filter and its frequency and phase response; iii. You should be able to select different windowing functions. Lab 1: Part B 2 Task 1: [Marks 25] The ideal low-pass filter coefficients can be expressed as ( ) 2 sinc(2 )c ch n F nF where Fc ( sc ffFc ) is the normalised cut-off frequency. i. Assume the cut-off frequency, fc = 200 Hz; sampling frequency, fs = 2000 Hz, values of n in the above equation mathematically be described as 2/)1(:2/)1(  NNn . Generate N = 31 numbers of filter coefficients (coefficients can also be generated using FDA tool from Matlab, see Appendix 2), and estimate the impulse response of low-pass filter. Repeat this for N = 65, 125 and 181 (odd number considered for liner phase response), plot their impulse, frequency and phase response, and comment. ii. Repeat the Task 1-i for different window function; hamming, hanning and blackman, comment on impulse response for each window function. Which window function you would select to avoid spectral leakage (Note: the default window is rectangle). [Hint: Use formulae given in Chapters 02, 03 and 04] Note: marks distribution, 14 for answers and 11 for source code (09[code] + 02[comments]). Task 2: [Marks 25] The ideal high-pass filter coefficients can be expressed as )2(sin21)( CC nFcFnh  where Fc is the normalised cut-off frequency. i. Assume the cut-off frequency, fc = 200 Hz; sampling frequency, fs = 2000 Hz, values of n in the above equation mathematically be described as 2/)1(:2/)1(  NNn . Generate N = 31 numbers of filter coefficients and estimate the impulse, frequency response of low-pass filter. Repeat this for N = 65, 125 and 181, plot impulse and phase response, and comment. ii. Repeat the Task 2-i for different window function; hamming, hanning and blackman, comment on impulse response for each window function. Which window would you select to avoid spectral leakage? Note: marks distribution, 14 for answers and 11 for source code (09[code] + 02[comments]). Task 3 [Marks 30] The process x(n) is sum of two signals S1 and S2; mathematically be described as: 21)( SSnx  where )2cos( 111 snTfAS  and )2cos( 222 snTfAS  A1 = A2 = 1; f1 = 10Hz; f2 = 50; fs =0.5kHz (sampling frequency). Complete the following tasks: i. Generate N = 2000 samples of the process x(n) and estimate the discrete spectrum using the fft function in Matlab. Plot the time and frequency domain of the processes x(n) . ii. Using FIR low-pass filter, remove signal S2, considering fc = 20Hz as a cut-off frequency and consider two sets of filter coefficients: 11 and 301. Plot the time and frequency domain of the filtered signal, and comment. Lab 1: Part B 3 iii. Using FIR high-pass filter, remove signal S1, considering fc = 20Hz as a cut-off frequency and consider two sets of filter coefficients, 11 and 301. Plot the time and frequency domain of filtered signal, and comment. [Hint: The output, y = convolution of input and filter coefficients, the Matlab syntax, y = conv(h,x); where h is filter coefficient array and x is any input signal array.] Note: marks distribution, 18 for answers and 12 for source code (10 [code] + 02[comments]). Task 4: [Marks 20] In Lab1 Task4-ii, you stored your audio signal with an additional frequency, f = 2000 Hz in it, using FIR low-pass filter with cut-off frequency fc = 1500 Hz, filter out the additional frequency. Plot the input and filtered signal in time and frequency domain, assuming filter coefficients number as 301. Save the filtered signal in .wav file (like you did in the Task 1), listen to the filtered audio and comment. Repeat the same process for different number of filter coefficients. Note: marks distribution, 10 for answers and 10 for source code (08[code] + 02[comments]). Lab 1: Part B 4 Appendix 1: Example (FIR) % ========================================================================= % Lab02 (Task1: Digital Filter), EEE8129 % ————————————————————————- % % ========================================================================= clear all; close all; clc; %% % ======================================================================== % 1. Define Filter type and its coefficients % ======================================================================== N = 31; % Number of filter coefficient fc = 0.2e3; % Cut-off frequency fs = 2e3; % Sampling frequency Fc = fc/fs; % Normalised cut-off frequency n = -(N-1)/2:(N-1)/2; % Number array for filter coefficients % ————————————————————————- % 1.1 FIR Low-pass filter % ————————————————————————- h = 2*Fc*sinc(2*n*Fc); %% Figure % ======================================================================== % 2. Frequency and Phase response % ======================================================================== figure(‘Units’,’centimeters’,’position’,[2 10 18 8]); stem([0:N-1],h); title(‘Filter coefficients’,’FontName’,’times new roman’,…. ‘FontWeight’,’bold’,’FontSize’,10); grid on; box on; xlabel(‘Normalised frequency (F)’); ylabel(‘Magnitude’); H = fft([h zeros(1,50*N)]); L = length(H); k = -(L-1)/2:(L-1)/2; F = k*0.5/((L-1)/2); % —– Frequency response —— figure(‘Units’,’centimeters’,’position’,[2 10 18 8]) plot(F,fftshift(abs(H))); title(‘Lowpass FIR filter’,’FontName’,’times new roman’,…. ‘FontWeight’,’bold’,’FontSize’,10); grid on; box on; xlabel(‘Normalised frequency (F)’); ylabel(‘Magnitude’); % —— Phase Response —— phase = fftshift(unwrap(angle(H))); phase1 = phase(1:(L-1)/2) – [phase((L-1)/2)+phase((L+3)/2)]; phase(1:(L-1)/2) = phase1; figure(‘Units’,’centimeters’,’position’,[2 10 18 8]); plot(F,phase); title(‘Linear Phase Response’); grid on; box on; xlabel(‘Normalised frequency (F)’); ylabel(‘Magnitude’); Appendix 2: Instruction for generating filter coefficients using FDA Tool, Matlab. Lab 1: Part B 5 1. In Matlab version 2013 and above, select APPS as shown in figure below; 2. From APPS, select Filter Design & Analysis illustrated in figure below; 3. Once you select Filter Design & Analysis, a new window will popup as shown in figure below; 4. In this window, user can select number of options to generate filter coefficients. The highlighted is illustrated in the given figure below, and after selecting these option, hit Design Filter; Lab 1: Part B 6 5. After generating the Filter Design, user can see impulse, frequecny, phase response and zeros and pole response shown in the series of the figures given below; Lab 1: Part B 7 Lab 1: Part B 8 6. The coefficients can be seen by selecting [ba] section underlined with red pen, the following coefficients can be copied into text file for filter design. Lab 1: Part B 9 7. The filter coefficients can also be stored using Export option in the File, and select Coefficients file (ASCII) from Workspace option; 8. The screenshot given below shows the list of filter coefficients. Lab 1: Part B 10 欢迎咨询51作业君

admin

Author admin

More posts by admin