% This assumes the soundfile is a single channel
[y, fs] = audioread('soundfilename');
Y = fft(y);
N = length(Y);
f = fs*(0:N-1)/N;
%plot(f, abs(Y)) % plot linear magnitude
%plot(f, angle(Y)) % plot phase
plot(f, 20*log10(abs(Y))); % plot magnitude in dB
xlim([0 fs/2])
xlabel('Frequency (Hz)');
ylabel('Magnitude (dB)');
| ©2004-2025 McGill University. All Rights Reserved. Maintained by Gary P. Scavone. |