> On 5 December 2010 11:39, Fredrik Lingvall <
address@hidden>
> wrote:
>>
>> 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
>
>
> Thanks for your valuable input at the expense of your time. But lets change
> gears --- lets do it at the back of the envelope --- I mean lets forget
> about the large data set that I attached earlier. And we go like:
>
> t = 0:0.1:28*60;
> T = linspace(min(t),max(t),numel(t))';
> signal = cos(2*pi*6*T) + randn(size(T));
> FFT_y = fft(signal);
> FFT_y = FFT_y(1:length(signal)/2+1);
> freq = linspace(0,1,numel(t)/2 +1);
> plot(freq,abs(FFT_y));
> title('A frequency Spectrum from FFT')
> xlabel('frequency [Hz]'); ylabel('Magnitude');
>
> With which I have a question: You see the artificial frequency is at 6Hz,
> but the plot locates the peak at 0.8Hz on a 0-to-1 frequency scale. How do I
> reconcile the observed value 0.8Hz to the expected value 6Hz?
>
> Or in other words: If I did not know a priori the artificial frequency, how
> could I derive it from the observed peak at 0.8Hz?
>
> Cheers,
> IDD
>
>
> * * * * * * * * * * * * * * *
> * Isak Delbert Davids *
> * +264-81-33 049 33 *
> * +264-61-206 3789 *
> * Namibia, Afrika *
> * * * * * * * * * * * * * * *
>