Hi everyone, I am new with matlab and am having problems with a spectral analysis problem i'm trying to do. I need to perform spectral analysis of a signal consisting of 1000Hz, 1000.1Hz and 999.9Hz i.e., x=cos(2*pi*1000*t)+cos(2*pi*1000.1*t)+cos(2*pi*999.9*t) so that all the three peaks are seen. This is to be done using a windowing function like blackmann-harris/guassian. I wrote the m-file to obtain peak for only one frequency. I'm totally stumned with how to obtained all three frequency peaks. Here's my m-file I'm working on. Any ideas on what to choose for the value of L, N and Fs ???? Any help would be great, since i've no idea on how to proceed. The m-file below gives me a peak at 999.9 Hz only and nothing at 1000 and 1000.1 Hz. Fs = 5000; % sampling frequency Ts = 1/Fs; % sampling period L = 25; % number of samples N = 1024*4; % number of points for FFT f1 = 1000 % analog frquency in Hz f2=1000.1 f3=999.9 A1 = 1.7; t = (0:L-1)*Ts; % array of sampled time from 0 to Ts*(L-1) x = A1*cos(2*pi*f1*t)+A1*cos(2*pi*f2*t)+A1*cos(2*pi*f3*t); % sampled signal X = fft(x,N); % take DFT of padded signal XX = fftshift(X) %center spectrum bin_inc = Fs/N, %compute the increment between discrete frequency bins f =[-N/2:(N/2-1)]*bin_inc; % create an array of frequencies figure plot(f, abs(XX)); % plot the magnitude annotated with frequency title('Rectangular') xlabel('frequency Hz') ylabel('magnitude') zzR = max(abs(XX)) ampR = zzR/N*2 % now use windows to process the data prior to performing FFT wb = window(@blackmanharris,L); xb = x.*wb'; % blackman window XB =fftshift(fft(xb,N)); % plot FFT figure plot(f, abs(XB)) title('Blackman-Harris'); xlabel('frequency Hz') ylabel('magnitude') zzB = max(abs(XB)) ampB = zzB/N*2 Thanks a lot in advance, waiting for reply. -Farah
DSP Spectral Analysis using MATLAB
Started by ●August 18, 2006
Reply by ●August 18, 20062006-08-18
"farah727rash@gmail.com" <farah727rash@gmail.com> wrote in news:1155903546.818338.17570@74g2000cwt.googlegroups.com:> The m-file below gives me a peak at 999.9 Hz only and nothing > at 1000 and 1000.1 Hz. >Instead of 1024*4 points in your fft, try using a nice round number, like 10,000 points. Matlab algoriths no longer require a power of 2. -- Scott Reverse name to reply