Trinh @ Bath

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision Both sides next revision
vpde_lecture34 [2020/04/21 08:38]
trinh created
vpde_lecture34 [2020/04/21 08:42]
trinh
Line 46: Line 46:
  
 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. 
 +
 +<Code:Matlab linenums:1 | Make a sound>
 +N = length(f2);
 +yhat = fft(f2);
 +A = abs(yhat)/N;
 +K = (Fs/2)*(1:ceil(N/2))/ceil(N/2);
 +A = A(1:ceil(N/2));
 +</Code>