regzarr

dsp lab 7

May 13th, 2021 (edited)
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.95 KB | None | 0 0
  1. function [] = firfilters(inputPath, outputPath)
  2.  
  3. [Y, FS] = audioread(inputPath); % read file
  4.  
  5. % plot input /*
  6. Y_fft = fft(Y);
  7. freqInitPlot = ((0:length(Y_fft) - 1) * FS) / length(Y_fft);
  8.  
  9. figure;
  10. plot(freqInitPlot, abs(Y_fft));
  11. xlabel('Frequency (Hz)');
  12. ylabel('Magnitude');
  13. title('Initial FFT magnitude');
  14. % */
  15.  
  16. % here I loaded the variables (@Num and @Den) saved by the filter tool
  17. % I chose to save them in a *.m file but you can also load them from the workspace
  18. % I couldn't figure out how so this was easier for me
  19. load('2ndtry');
  20. Z = filter(Num, Den, Y);
  21.  
  22. % plot output /*
  23. Z_fft = fft(Z);
  24. freqInitPlot = ((0:length(Z_fft) - 1) * FS) / length(Z_fft);
  25.  
  26. figure;
  27. plot(freqInitPlot, abs(Z_fft));
  28. xlabel('Frequency (Hz)');
  29. ylabel('Magnitude');
  30. title('Output FFT magnitude');
  31. % */
  32.  
  33. audiowrite(outputPath, Z, FS); % write output file
  34.  
  35. zoom xon; % don't remember what this does, something to do with graphs, 99% sure it's unnecessary
  36. end
Add Comment
Please, Sign In to add comment