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: Fredrik Lingvall
Subject: Re: FFT: Finding signal frequency at wrong place
Date: Sun, 05 Dec 2010 10:39:03 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101106 Lightning/1.0b3pre Thunderbird/3.1.6

On 12/05/10 10:04, Isak Delberth Davids wrote:

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

Try,

freq = (0:length(signal)-1)/length(signal)*freqsamp;
plot(freq,20*log10(abs(fft(signal)))); % dB scale
ax = axis;
axis([0 freqsamp/2 ax(3) ax(4)]);


/Fredrik

reply via email to

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