Advertisement
regzarr

lab8 DSP

May 25th, 2021
1,053
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.68 KB | None | 0 0
  1. function [] = dft(inputPath, outputPath)
  2.  
  3. [Y, FS] = audioread(inputPath);
  4.  
  5. Z = Y;
  6.  
  7. Fs = 1000; % samples per second
  8. dT = 1/Fs; % seconds per sample
  9. stopTime = 0.2;
  10. t = (0:dT:stopTime-dT)';
  11.  
  12. figure;
  13. plot(t,Y);
  14. xlabel('Time (s)');
  15. ylabel('Amplitude');
  16. title('Input wave vs time');
  17.  
  18. Y_fft = fft(Y);
  19.  
  20. for i = 1:length(S_fft)
  21.     if (abs(S_fft(i)) < (10 ^ (-5)))
  22.         S_fft(i) = 0;
  23.     end
  24. end
  25.  
  26. freq = ((0:length(S_fft)-1) * Fs) / length(S_fft);
  27.  
  28. figure;
  29. plot(freq,abs(S_fft));
  30. xlabel('Frequency (Hz)');
  31. ylabel('Magnitude');
  32. title('FFT magnitude');
  33.  
  34. figure;
  35. plot(freq,angle(S_fft));
  36. xlabel('Frequency (Hz)');
  37. ylabel('Phase');
  38. title('FFT phase');
  39.  
  40. zoom xon;
  41. end
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement