Posted by: madhab6 February 20, 2009
URGENT HELP-------------MATLAB
Login in to Rate this Post:     0       ?        

Here U go dude:


clear all;


close all;


clc;


% import a auio sample


[y,Fs,nbit]=wavread('your_audio.wav');


% extract left channel only


left=y(:,1);


% calculate the time scale


Ts=1/Fs;


[nsamples,c]=size(y);


tscale=0:Ts:(nsamples-1)*Ts;


%plot left and right channel in time domain


plot(tscale,left,'r');


xlabel('Time (sec)');


ylabel('Amplitude');


%compute the FFT with the proper sampling frequency


fmax=Fs;


%how many points the FFT must be computed on?


N=nsamples;


tscale=0:Ts:(N-1)*Ts;


%N=number of FFT points:


% change it and test the different resolution


fscale=linspace(0,fmax/2,floor(N/2));


spectrum=fft(left,N);


%plot the spectrum of the signal using the appropriate


% frequency scale and module of the coefficients


%plot the magnitude


figure(2);


plot(fscale,abs((spectrum(1:length(fscale)))));


xlabel('Frequency Hz')


ylabel('Module')

Read Full Discussion Thread for this article