Hi Jan, You are correct that k is the index corresponding to frequency. In an fft, k = 6 always corresponds to 6 oscillations over the entire time period, whatever the period happens to be. Here the period is 72 months so k corresponds to 6 oscillations in 72 months, i.e. one oscillation per year. Similarly k = 12 corresponds to two oscillations per year, and k = 1 is one oscillation over the entire 72 months. In the tutorial those frequency peaks are the largest so just those are used in the reconstruction. (k=0, the constant term, would have been the largest but it was removed).
frequency domain linear regression
3 次查看(过去 30 天)
显示 更早的评论
First, is about frequency bin termin. In this tutorial we have frequency bin for positive and negative frequency, and it can be calculated like lengths of time series / period of time series + 1, for positive frequencies. For negative frequencies frequency bin is length of time series - lengths of time series / period of time series + 1. In my example, length of time series is odd number and I need to use it later like index in other time series, but than I have decimal number. I am not sure, what to do and is this principle of calculating frequency bins ok?
%
freqbin = 72/12;
freqbins = [freqbin 72-freqbin]+1;
tsfit = zeros(72,1);
tsfit(freqbins) = tsdft(freqbins);
tsfit = ifft(tsfit);
mu = mean(ts);
tsfit = mu+tsfit;
Second, at the and of tutorial we need to form linear regression model. X matrix which is neccessary for that is formed here like:
X = ones(72,7);
X(:,2) = cos(2*pi/72*(0:71))';
X(:,3) = sin(2*pi/72*(0:71))';
X(:,4) = cos(2*pi*6/72*(0:71))';
X(:,5) = sin(2*pi*6/72*(0:71))';
X(:,6) = cos(2*pi*12/72*(0:71))';
X(:,7) = sin(2*pi*12/72*(0:71))';
I don't understand from where they get numbers 6 and 12 in sin and cos term? This model is opposite of model formed with 3 Fourier frequencies, or 6 Fourier coefficients, but I can't find rule for numbers 6 and 12. Linear model need to have terms cos(2*pi*k*n/N) and sin(2*pi*k*n/N), where n is number of that term, N length of time series, and is k frequency?
0 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Polynomials 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!