LABIn this lab, we will understand direct computation of spectra, Discrete and Fast Fourier Transforms (DFT and FFT, respectively).NOTE: Each time you see a new MATLAB command, please go to MATLAB...

1 answer below »
LABIn this lab, we will understand direct computation of spectra, Discrete and Fast Fourier Transforms (DFT and FFT, respectively).NOTE: Each time you see a new MATLAB command, please go to MATLAB Help and read the documentation on this command. You might need to use it in the future.Your goal is to populate all of the empty code gray boxes to replicate the presented results. Please submit the MATLAB code in a single M-file.Direct Computation at one FrequencyRead the file Tuning fork.mp3 and show its sampling interval (1/(sampling frequency)). Calculate the number of samples in that signal.clcclose allclearvars[x, Fs] = audioread('Tuning fork.mp3');???
Now, we will compute amplitude spectrum value for a specific frequency (i.e., ). This frequency is typical for a European concert pitch https://en.wikipedia.org/wiki/Concert_pitch. The tuning fork should resonate at this frequency. Compute the Discrete Fourier Transform for above signal using the formula given below just for this specific omega. (1)Also calculate computation time. Hint: Use tic and toc.
tocAs it can be seen from above results (your timing might be different), it takes only a few milliseconds to compute , which involves hundred thousand additions and multiplications, at a single frequency.Discrete Fourier Transform (DFT)If we use (1) to compute the spectrum of , we must compute at a large number of frequencies. Because is periodic with period , we need to compute for only in a frequency range of . The range consists of infinitely many , and we cannot compute them all. We can compute only a finite number of . Let us select the number of to be , same as the number of samples used in (1). These fequencies are to be equally spaced. Because is periodic with period , we can select frequency range as . for (2)Substituting (2) into (1) yields (3)Let us define , for , and . Then (3) can be written as: (4)This equation transforms data points , for into data points , for and is called the (DFT). It is also possible to develop inverse DFT.Fast Fourier Transform(FFT)There are N terms in the summation of (4). Thus computing each requires multiplications and computing, for , requires a total of multiplications. To compute data, if the number of operations is proportional to , it is a curse because increases rapidly as increases. Thus direct computation of is not desirable.If we divide into two subsequences of length and then carry out the computation of (4), the number of operations can be cut almost in half. If is a power of 2, we can repeat the process times. Thus, the number of operations can be reduced to be proportional to . Based on this idea, many methods, called collectively the (FFT), were developed to compute (4) effectively.The use of FFT in MATLAB is very simple. For a set of data points expressed as a row vector, typing will yield entries which are the values of , for , in (4). For example, for x1=[1,-2,1], its Fourier transform X1 is:
The spectrum is complex, its magnitude and phase can be computed as follows:Since the spectrum is complex, compute it's magnitude and phase using , respectively.


In conclusion, if x is a row vector of real values, then will generate a row vector of complex values.Plotting Spectra for frequencyWe compute and plot the magintude spectrum of . It makes sense to plot only a half of the frequencies, because the other half will be symmetrical. The phase spectrum will not be plotted, because it may not be correct due to numerical computation. We list the procedure below:Compute fft of a Tuning fork signal and divide it by the number of samples. Use tic and toc to measure the processing time.Plot twice the absolute value of the result as a function of frequency up to . Use f = Fs*(0:(N/2))/N scale for frequencies.Hint: see the help demos for fft.


Note that the time for computing 386544 frequencies using fft is shorter than the time to compute a single frequency using the direct way.Now, zoom into the area of [420,460] Hz using xlim function.
You may see that the tuning fork generates the maximal response around 443Hz, as expected.Plotting Spectra for frequencySometimes it is convenient to shift the origin of the frequency to the middle and then to plot positive and negative frequencies. For that, we could use the command fftshift:
SpectrogramMost natural signals are not stationary, thus their properties (including spectrum) are changing in time. If we take the entire signal and compute its spectrum, it will give us all of the frequencies that ever appeared in the signal at some point of time, but spectrum will not tell us when those frequencies appeared. For this additional information, we need to use a spectrogram. One axis of a spectrogram if frequency, and another is time. The value of amplitude spectrum is denoted by brightness or color.Let's plot a spectrogram of the tuning fork signal:spectrogram(x,2048,2000,0:5:5000,Fs,'yaxis')Note that at the beginning of the mp3 file there is about half a second of silence, then there is a strong response close to 0.5kHz and 2.7 kHz. Then the higher pitched response vanishes and only the main (f=443 Hz) response stays (with secondary harmonic near 2f=886 Hz). Also, there are slightly visible responses at 3f,4f,5f,... Could you explain why?Play with different parameters of spectrogram function to see how they affect the image and write your conclusions as a comment for the code.
Answered 1 days AfterFeb 14, 2022

Answer To: LABIn this lab, we will understand direct computation of spectra, Discrete and Fast Fourier...

Sathishkumar answered on Feb 16 2022
111 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here