FFT confusion [message #35218] |
Thu, 15 May 2003 07:15 |
jefield
Messages: 3 Registered: January 2003
|
Junior Member |
|
|
Hi,
I'd be enormously grateful if anyone could help me with this.
I'm looking at the power spectra of "chirp" radio signals and am
having problems getting sensible plots. The following code should
generate a complex sinusoidal chirp whose frequency runs from 100 to
150 Hz and then plot its power spectrum:
pro spec
time = (2.0/1000)*findgen(1001) ; time (s). NB 1001 samples in 2s
; so sampling freq is 500 Hz thus
; Nyquist freq is 250 Hz
freq = 100.0 + (50.0/1000)*findgen(1001) ; chirp frequency array
theta = 2*!pi*freq*time ; chirp phase angle
i = complex(0,1)
signal = exp(i*theta)
neg_freq_axis = reverse(-((250.0/500)*findgen(501)))
pos_freq_axis = ((250.0/499)*findgen(500)) + 1.0
freq_axis = [neg_freq_axis,pos_freq_axis] ; x-axis for plot
window,2,xsize=500,ysize=250
plot,freq_axis,alog10(shift(((abs(fft(signal)))^2),500)),$
xrange=[0,260],$
/xstyle,$
xticklen=1,$
xgridstyle=1,$
yticklen=1,$
ygridstyle=1
end
However I'm getting a frequency spectrum running from 100 to *200* Hz
and I'm really confused. This problem has been bugging me for ages and
I'd be very grateful if anyone could point out my mistake(s).
Thanks very much!
Julian
|
|
|