DSPRelated.com
Forums

fft problem

Started by lolo_mk1 June 6, 2005
Hi

I've been having some problems with the fft() function in matlab. I
ran a simple test...

x = 0:1/460800:0.1; % sample rate = 460800 Hz
fx = sin(2*pi*30000*x); % sine wave @ 30000 Hz

Y = fft(fx, 4096); % take first 4096 samples and fft
Pyy = Y.*conj(Y); % power spectrum
logPyy = 10*logPyy; % convert to dB

f = 460800*(0:2048)/4096; % create x-axis scale
plot(f, logPyy(1:2049)); % plot... There may be errors in the script but I wrote it off the top of my
head and I'm pretty sure the idea is right (I don't have matlab on
the computer I'm writing the email from)...

The resulting plot does have a peak at 30000 Hz at around +30 dB but
on each side of the peak is a hyperbolic shape with an asymptote at
around -40 dB. I thought that with a perfect sine wave the spike
should be sharper, perhaps reaching -100 dB (or more) and achieving
this quickly (for example if the fundamental frequency is 30000 Hz,
by 50000 Hz I would be expecting at least -100dB).

Does anyone know why it is doing this? Can it be fixed or is it
unavoidable when using a fft ?

Thanks

Aaron



El 07/06/2005, a las 1:30, lolo_mk1 escribi

> Hi
>
> I've been having some problems with the fft() function in matlab. I
> ran a simple test...
>
> x = 0:1/460800:0.1; % sample rate = 460800 Hz
> fx = sin(2*pi*30000*x); % sine wave @ 30000 Hz
>
> Y = fft(fx, 4096); % take first 4096 samples and fft
> Pyy = Y.*conj(Y); % power spectrum
> logPyy = 10*logPyy; % convert to dB
>
> f = 460800*(0:2048)/4096; % create x-axis scale
> plot(f, logPyy(1:2049)); % plot... > There may be errors in the script but I wrote it off the top of my
> head and I'm pretty sure the idea is right (I don't have matlab on
> the computer I'm writing the email from)...
>
> The resulting plot does have a peak at 30000 Hz at around +30 dB but
> on each side of the peak is a hyperbolic shape with an asymptote at
> around -40 dB. I thought that with a perfect sine wave the spike
> should be sharper, perhaps reaching -100 dB (or more) and achieving
> this quickly (for example if the fundamental frequency is 30000 Hz,
> by 50000 Hz I would be expecting at least -100dB).
>
> Does anyone know why it is doing this? Can it be fixed or is it
> unavoidable when using a fft ?

Just by using logPyy = 10*log(Pyy) I get > 140dB peaks... --
Juan de Dios Santander Vela
Diplomado en CC. Ficas, Ingeniero en Electrica
Doctorando en Tecnologs Multimedia
Becario Predoctoral del Instituto de Astrofica de Andaluc

Wilfred Funk: Cuantas m palabras conozcas, m clara y
poderosamente pensar... y m ideas invitar a tu mente.