EEE8129 (PART A) –Intelligent Signal Processing Lab Assignment Due Date: Friday January 15, 2021 by 2:00 PM Word limit: 4000 Note: There will be one report submission for all three Lab1: Parts A, B & C. Lab1: Part A 2 Title: Introduction to signals in the time and frequency domain Lab Overview This lab consists of four Tasks. Objectives The objectives of this lab are as follows: i. Gain familiarity with signals in time and frequency domain; ii. Understand the computational cost of the DFT and FFT; iii. You should be able to explain spectral leakage due to windowing; iv. You should also understand how different windows (Hamming, Hanning etc) reduce leakage effects. Lab Submission i. There will be one combined report for all three parts of Lab 1 (Parts A, B & C); ii. Students are required to submit both a soft copy; iii. The soft copy should be in word or pdf format and include your Matlab program; iv. The Matlab code should be included in the appendix of your report; v. Please save your report and Matlab files in the given format: LastName_FirstName_StdID_LabNo.doc (pdf or m). For example, if Student’s name is Roni Joseph, student ID: 1001, Lab 01, then the file name should be, Joseph_Roni_1001_Lab01.doc (if a Word file, .pdf is for a PDF file). For the Matlab file: Joseph_Roni_1001_ Lab01.m; you can include all tasks in one Matlab file or multiple Matlab files for individual tasks. For multiple Matlab files, please add task no, for example Joseph_Roni_1001_ Lab01_Task1.m; vi. Students are required to write mathematical formulae wherever required and references should be cited in your report; vii. You must add comments to your Matlab script. 2 marks will be awarded for adding good comments; viii. Your lab report as a whole should be well written and easy to understand. Figures should have captions and be properly labelled use legends if required. All figures and table should be cited in the text. ix. SCHOOL POLICY FOR LATE SUBMISSIONS: If you submit your report late, but within 7 days of the deadline, your mark will be capped at the pass mark (40% for undergraduate students and 50% for postgraduate students). Any later than 7 days and you will receive no marks. x. If you have a valid reason for not submitting your report on time, then you should submit a personal extenuating circumstances (PEC) form to the School office, Lab1: Part A 3 Task 1: [Marks 15] Plot and compare the computational cost (no of additions and multiplications) between the DFT and FFT for data points N = 2 to 4096. If you are to select DFT or FFT for designing any source code, which one would you select? Justify your selection. [Hint: Use formulae given in EEE3004_Ch02_Slides.pdf file, slide 26] No. of multiplication No. of Addition DFT N2 N(N-1) FFT (N/2)log2N Nlog2N Note: marks distribution, 10 for answer and 5 for source code (03[code] + 02[comments]). Task 2: [Marks 30] The process x(n) to be considered can mathematically be described as: )2cos()2cos()( 2211 ss nTfAnTfAnx where: A1 = A2 = 10; f1 = 0.2Hz; f2 = 0.225; Ts =1 sec (sampling frequency). Complete the following tasks: i. Generate N = 64 samples of the process x(n) and estimate the discrete spectrum using the fft function in Matlab. Repeat this for N = 128, 256 and 512 points. Plot the discrete spectrum and compare the effect of different data points. [Hint: Use the command stem in Matlab. The spectrum exists as complex number and hence, you may plot the magnitude response only. A continuous spectrum can be obtained by joining the discrete points of the FFT output. To do this, simply use the command plot in Matlab.] ii. Now rescale the frequency axis using Hz as a unit and plot the full range of positive frequencies [0, fs]. If we were to view the spectrum from –fs/2 to fs/2, sketch what this spectrum will look like. Note: marks distribution, 20 for answers and 10 for source code (08[code] + 02[comments]). Task 3: [Marks 20] Investigate the effects of spectral leakage in Task 2 by varying N. Comment on the shape of the spectrum and how it deviates from the ideal response where the number of samples is infinite. Try with different windows: Hamming, Hanning and Blackman. [Hint: Use the command hamming, hanning and blackman in Matlab; default is a rectangular window.] Note: marks distribution, 10 for answers and 10 for source code (08[code] + 02[comments]). Task 4: [Marks 30] Complete the following task: i. Record your audio for 10 sec using the microphone and the Matlab script given below, with the sampling frequency, fs = 8000 Hz. Plot your audio in the time domain and its spectrum. Lab1: Part A 4 ii. Assume your audio single is x(n), )2cos()( 11 snTfAny is an arbitrary signal (A1 = 1; f1 = 2000 Hz), and the sum of x(n) and y(n) is z(n) = x(n) + y(n). Save the z(n) array as an audio file (.wav), listen to the resultant audio file and compare with the previous one. Comment on the quality of the audio and plot the new audio signal in the time and frequency domain. Note: marks distribution, 20 for answers and 10 for source code (08[code] + 02[comments]). %% Audio Data Collection Fs = 8000; % Sampling Frequency Ts = 1/Fs; % Sampling interval t_Period4AudioSig = 10; % Total time for audio signal timeArray = 0:Ts:t_Period4AudioSig; N_DataPoint = length(timeArray); recObj = audiorecorder(Fs,8,1); % Syntax required for recording using Matlab % --------- This display syntax ------------------------------------------- clc % Clear Matlab Command Window Screen disp('==================================================') disp('Start speaking and continue until next message ...') % The recordblocking command is audio recording, an additional .05 sec in syntax below is to avoid any system delay recordblocking(recObj, t_Period4AudioSig+.05); disp(' '); disp(' End of Recording'); disp('==================================================') % ------------ Store the audio data array --------------------------------- myAudioSig = getaudiodata(recObj); finalAudioSig = myAudioSig(1:N_DataPoint,1)'; % ------------- Plot my Audio signal -------------------------------------- plot(timeArray, finalAudioSig); % ------------- Listen my Audio Signal ------------------------------------ play(recObj); % ------------- Save array into .wav file [which can played in media player] – Wavewrite(finalAudioSig, 'myAudio.wav'); Lab1: Part A 5 Appendix: [Marks 5] Example (FFT) % ========================================================================= % Lab01, EEE8129 % % % ========================================================================= clear all; close all; clc; %% % ======================================================================== % 1. Generating Time-domain discrete signal % ======================================================================== N = 8; % N number of DFT point fs = 16; % Sampling frequency Ts = 1/fs; % Sampling interval To = N*Ts; % Window size (one period) t = 0:Ts:(N-1)*Ts; % Sampling interval f1 = 4; % ------------------------------------------------------------------------- % 1.1 Trigonometric function x(t) % ------------------------------------------------------------------------- x = 1*cos(2*pi*f1*t); % Time-domain signal % ------------------------------------------------------------------------- % 1.2 Figure (time-series of x(t) or x(n) ) % ------------------------------------------------------------------------- figure('Units','centimeters','position',[2 10 10 5]) stem(t,x,'or') hold on; plot(t,x,':') hold off legend('x(n)', 'x(t)');legend('boxoff') title('Time-series of signal [x = 2cos(2\pi f_1 t)]',... 'FontName','times new roman','FontWeight','bold','FontSize',10); xlabel('Time [(n) or (t)] --->','FontName','times new roman','FontSize',10); ylabel('Amp','FontName','times new roman','FontSize',10) %% % ======================================================================== % 2. Frequency-domain of discrete signal % ======================================================================== X = fft([x zeros(1,0*N)]); M = length(X); k = 0:M-1; % Discrete frequency: bins f = k*fs/M; % Continuous frequency % Figure figure('Units','centimeters','position',[14 10 10 8]) subplot(211), stem(k,abs(X),'.'), title('Discrete Fourier Transform \Sigma'), xlabel('normalised frequency (k=f*N/f_s)');ylabel('Magnitude') subplot(212), plot(f,abs(X)*Ts/To), title('Reconstructed Fourier Transform'), xlabel('frequency (Hz)');ylabel('Magnitude')
欢迎咨询51作业君