This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
vpde_lecture34 [2020/04/21 08:38] trinh created |
vpde_lecture34 [2020/04/23 08:16] (current) trinh |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Lecture 34: The maths of music I ====== | ====== Lecture 34: The maths of music I ====== | ||
| + | |||
| + | < | ||
| + | <iframe width=" | ||
| + | </ | ||
| ===== The Fourier spectra ===== | ===== The Fourier spectra ===== | ||
| Line 46: | Line 50: | ||
| The last thing I want to show you today is how a computer stores the information of a signal in terms of a Fourier series. Rather than store information about sines and cosines separately, it is more compact to work with complex-valued functions and store the information together. | The last thing I want to show you today is how a computer stores the information of a signal in terms of a Fourier series. Rather than store information about sines and cosines separately, it is more compact to work with complex-valued functions and store the information together. | ||
| + | |||
| + | Matlab uses the fft command to calculate the Fourier series of a signal (technically the discrete Fourier transform). I will not explain it in detail at this point. What you have to understand is that you can put a vector into fft, but to plot the Fourier amplitudes, you need to rearrange the output in a funny way. | ||
| + | |||
| + | < | ||
| + | N = length(f); | ||
| + | yhat = fft(f); | ||
| + | A = abs(yhat)/ | ||
| + | K = (Fs/ | ||
| + | A = A(1: | ||
| + | plot(K, A) | ||
| + | </ | ||
| + | |||
| + | (We noticed during the lecture that the above code is flawed by 1 element, as it indicates a peak frequency of 441Hz instead of 440Hz! I believe this is because you have to ' | ||