Trinh @ Bath

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
vpde_lecture34 [2020/04/21 11:25]
trinh
vpde_lecture34 [2020/04/23 08:16] (current)
trinh
Line 54: Line 54:
  
 <Code:Matlab linenums:1 | Make a sound> <Code:Matlab linenums:1 | Make a sound>
-N = length(f2); +N = length(f); 
-yhat = fft(f2);+yhat = fft(f);
 A = abs(yhat)/N; A = abs(yhat)/N;
 K = (Fs/2)*(1:ceil(N/2))/ceil(N/2); K = (Fs/2)*(1:ceil(N/2))/ceil(N/2);
 A = A(1:ceil(N/2)); A = A(1:ceil(N/2));
 +plot(K, A)
 </Code> </Code>
 +
 +(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 'dump' one of the vector components).