help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: FFT: Finding signal frequency at wrong place


From: Isak Delberth Davids
Subject: Re: FFT: Finding signal frequency at wrong place
Date: Sun, 5 Dec 2010 11:04:44 +0200

On 5 December 2010 09:05, Judd Storrs <address@hidden> wrote:
On Sat, Dec 4, 2010 at 3:51 PM, Isak Delberth Davids
<address@hidden> wrote:
> I do a FFT on the attached strictly increasing time data of gamma-ray
> signals as observed. I try to find any embedded frequencies. First I check
> if the code below works for user-defined frequencies. I thus add two known
> sine waves. Running the code, I find two frequencie, but at definitely wrong
> frequencies. Do I mess with frequency scaling or what? I expected the peaks
> near 0.1 and 0.05. Code at end

I'm not familiar with gamma-ray signals and how to use the FFT to get
the frequencies (Is 't' a list of times that a gamma-ray was
detected?) However, I do know why you are not seeing your expected
peaks. The FFT expects uniformly sampled data and the 't' is not
uniformly sampled. In other words, after:

t = t + ampl*sin(2*pi*freq_test1*t) +  ampl*sin(2*pi*freq_test2*t);

The artificial peaks will only show up correctly if diff(t) is
constant. For example, if you make a change like this:

T = linspace(min(t),max(t),numel(t))' ;
t = t + ampl*sin(2*pi*freq_test1*T) +  ampl*sin(2*pi*freq_test2*T);

Then you will see two peaks added to your spectrum.


--judd

Thanks Judd, was the line you suggested intentionally

t = t + ampl*sin(2*pi*freq_test1*T) +  ampl*sin(2*pi*freq_test2*T);

and was not meant to be

t = T + ampl*sin(2*pi*freq_test1*T) +  ampl*sin(2*pi*freq_test2*T);

BTW, assuming the latter, I revisited the following:
** avoiding multiple use of 't' I call the operand of FFT the 'signal',
** to get freq_samp I must not divide by 60, as that will give units of '"per minute". I need secs
** yes, 't' is the time at which a gamma-ray photon is detected in seconds after a reference time t_0 = 0 secs by a ground-based array of telescope dishes (simultaneously) --- so these are photon arrival time-stamps,
** I changed "freq = (freq_samp/2)*linspace(0,1,nFFT/2+1)" into "freq = linspace(0,1,nFFT/2+1)"
** after using linspace on 't' as suggested, the code takes a new shape below.

load time_series.dat
dataMatrix = time_series;
t = dataMatrix(:,1);
t_obs = max(t)-min(t);
L = length(t);
freq_samp = 1/t_obs; % sampling frequency
freq_test1 = 0.3;
freq_test2 = 0.5;
ampl = 10^4;
T = linspace(min(t),max(t),numel(t))' ;
signal = t + ampl*sin(2*pi*freq_test1*T) +  ampl*sin(2*pi*freq_test2*T);
nFFT = 2^nextpow2(L);
Y_fft = fft(signal,nFFT)/L;
freq = linspace(0,1,nFFT/2+1);
plot(freq,2*abs(Y_fft(1:nFFT/2+1)))

My problem of frequency VALUES remains: The peaks that I see are somehow off-set from the expected frequency positions. Is my frequency scaling in order?

Cheers,
           Isak

* * * * * * * * * * * * * * *
*  Isak Delbert Davids *
*  +264-81-33 049 33  *
*  +264-61-206 3789   *
*    Namibia, Afrika     *
* * * * * * * * * * * * * * *


reply via email to

[Prev in Thread] Current Thread [Next in Thread]