% ex91.m fn = input('Enter WAV filename : ','s'); [x,fs,nb] = wavread(fn,1024); t = (0:1023)/fs; % get sample times y = x.*hamming(1024); % window Y = fft(y,1024); % do FFT Y = Y(1:512); % get lower Fs/2 f = (0:511)*fs/1024; % frequencies subplot(2,1,1); plot(t,y); % plot waveform at top subplot(2,1,2); plot(f,20*log10(abs(Y)+eps)); % plot spectrum at bottom