Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [] = dft(inputPath, outputPath)
- [Y, FS] = audioread(inputPath);
- Z = Y;
- Fs = 1000; % samples per second
- dT = 1/Fs; % seconds per sample
- stopTime = 0.2;
- t = (0:dT:stopTime-dT)';
- figure;
- plot(t,Y);
- xlabel('Time (s)');
- ylabel('Amplitude');
- title('Input wave vs time');
- Y_fft = fft(Y);
- for i = 1:length(S_fft)
- if (abs(S_fft(i)) < (10 ^ (-5)))
- S_fft(i) = 0;
- end
- end
- freq = ((0:length(S_fft)-1) * Fs) / length(S_fft);
- figure;
- plot(freq,abs(S_fft));
- xlabel('Frequency (Hz)');
- ylabel('Magnitude');
- title('FFT magnitude');
- figure;
- plot(freq,angle(S_fft));
- xlabel('Frequency (Hz)');
- ylabel('Phase');
- title('FFT phase');
- zoom xon;
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement