This preview shows page 1. Sign up to view the full content.
Unformatted text preview: %reads in the sound file and gets the data and the sampling frequency subplot(1,2,1); %first position in the subplot dt = 1./fs; duration = length(snd)./fs; %finds the duration of the sound file timevec = linspace(dt,duration,duration.*fs); %creates a time vector to plot the data against plot(timevec,snd); %plots the data title('Time Domain Plot'); xlabel('time (sec)'); ylabel('amplitude'); %labels the title and axes of the plot % subplot(1,2,2); %second position in the subplot y = 2.*abs(fft(snd))./length(snd); y = y(1:round(end/2)); %Fast-Fourier Transform equations f_nyquist = fs./2; %gets the Nyquist value freqs = linspace(0,f_nyquist,length(y)); %gets the vector for the frequency values [mx ind] = max(y); princfreq = freqs(ind); %above two lines find the maximum frequency plot(freqs,y,'b',princfreq,mx,'rx'); %plots the data title('Frequency Domain Plot'); xlabel('frequency (Hz)'); ylabel('normalized magnitude'); %labels the title and axes of the plot end...
View Full Document
This note was uploaded on 10/21/2010 for the course CS 1371 taught by Professor Stallworth during the Spring '08 term at Georgia Institute of Technology.
- Spring '08