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