sal22 <sal22@please_post_to_group.com> wrote in message <Nvb3t.38741$lR.email@example.com>... > Greetings All > > I have an fft function in matlab/octave that works great on an imported mono wav/audio signal that is 1 second long, but when the signal imported is more than 1 second the frequency values become incorrect. To check this I created a 2 second signal using audacity the first half of the 2 second signal (1 second of it) was 500hz at 0.3 amplitude and the second half of the 2 second signal (1 second of it) was 200hz at 0.8 amplitude. I also checked it with audacity's analyse spectrum option. > > When I use the function on this 2 second signal it shows that the max frequency is at 999.95hz when it should show the max frequency is at 200hz. Can anyone help me get this function to work with signals greater than just 1 second.
dt = 1/Fs T = N*dt t = dt*(0:N-1); t = 0:dt:T-dt; tmax = T- dt
df = 1/T df = Fs/N f = df*(0:N-1); f = 0:df:Fs-df; fmax = Fs-df
If you increase the length of the time signal with data or zeropadding, dt and Fs remain constant while N, T and tmax are changed to M, Tm = M*dt and tmax = Tm-dt = (M-1)*dt.
dfm = 1/Tm dfm = Fs/M fm = dfm*(0:M-1); fm =0:dfm:Fs-dfm fmmax = Fs-dfm
Therefore the maximum frequency is not significantly changed. Only the spacing is decreased df --> dfm = (N/M)*df.
> % This is an evenly spaced frequency vector with NumUniquePts points. > freq_vect = (0:NumUniquePts-1)*vp_sig_len/nfft;