Sunday 15 June 2014

Finding the dominant frequency of a time series data using fft matlab -


I am trying to determine the main frequency of time series data using the fft function in matlab. My data is represented as a vector, while my time scale is also a vector. Below is my sample code:

  Fs = 10; % Sampling frequency 1 kHz t = [0,10,20,30,40,50,60,70,80,80,90]; % Time scale x = [10,120,130,120,120,100,123,456,78,8 9]; The plot of time series (T, X), axis ('tight'), grid ('on'), title ('time series'), Figure nfft = 512; Next big strength of% 2 = fft (x, nfft); Fast Fourier conversion y = ab (y ^ 2); % Raw power spectrum density y = y (1: 1 + nfft / 2); % Half-spectrum [v, k] = maximum (y); Find the maximum F_scale = (0: nfft / 2) * FS / NFFT; Plot of% frequency scale (f_scale, y), axis ('tight'), grid ('on'), title ('major frequency') fest = f_scale (k); % Effective frequency estimation fprintf ('major freq.: True% f hz, estimated% f hznn', f, fest) fprintf ('frequency phase (resolution) =% f hznn', f_scale (2))  < / Pre> 

The problem is that my main frequency here is 0, which is not perfect if it is correct. Some can provide feedback on this, especially if FS are doing a lot in this case!

try the following

1) generate signals with multiple frequencies

x = 0: 0.1: 100;

y = 0;

I = 1:10,

y = y + sin (2 * pi * rand (1) * 10 * x);

Terminate

2) Use FlatWindow as a window window to obtain the pwelch Power Spromet, it ensures that the scrolling loice is small (the dimension of the signal is correct 3) Use scaling eq (11) in [link] to get the right dimension.

4) Check the dimension: Change the PSD to a linear spectrum -> It is not necessary though, I often want to know the value of the dimension. However, be aware that the pwelch RMS-dimension does not count the peak-dimension Sqrt (2) to multiply the peak-dimension.

Best, Jonas


No comments:

Post a Comment