문제

I am attempting to analyse a time series with spectral analysis. I am trying to detect any periodicities in my data, which is composed of hourly measurements recorded for one week (24 * 7 = 168 measurements), I aim to show the diurnal component of the temperature variation. So far I have (for example):

clear all
StartDate = '2011-07-01 00:00';
EndDate = '2011-07-07 23:00';
DateTime=datestr(datenum(StartDate,'yyyy-mm-dd HH:MM'):60/(60*24):...
    datenum(EndDate,'yyyy-mm-dd HH:MM'),...
    'yyyy-mm-dd HH:MM');
DateTime=cellstr(DateTime);
DecDay = datenum(DateTime)-datenum(2011,0,0);
t = 0:25/length(DecDay):(25-0.1488);
x = sin(2*pi*50*t) + sin(2*pi*120*t);
y = x + 2*randn(size(t));
Y = fft(y,length(y));

Where would I go from here? any advice would be much appreciated.

Altered:

clear all
    StartDate = '2011-07-01 00:00';
    EndDate = '2011-07-07 23:00';
    DateTime=datestr(datenum(StartDate,'yyyy-mm-dd HH:MM'):60/(60*24):...
        datenum(EndDate,'yyyy-mm-dd HH:MM'),...
        'yyyy-mm-dd HH:MM');
    DateTime=cellstr(DateTime);
    DecDay = datenum(DateTime)-datenum(2011,0,0);
 x = cos((2*pi)/12*DecDay)+randn(size(DecDay));
 % if you have the signal processing toolbox
 [Pxx,F] = periodogram(x,rectwin(length(x)),length(x),1);
 plot(F,10*log10(Pxx)); xlabel('Cycles/hour');
 ylabel('dB/(Cycles/hour');

Can anyone suggest how I would convert the x axis to hours instead of cycles per hour? I have tried

plot(1./F,10*log10(Pxx)); xlabel('hours');

but this messes up the peridogram.

도움이 되었습니까?

해결책

You may find it easier to start off with MATLAB's periodogram function, rather than trying to use the FFT directly. This takes care of windowing the data for you and various other implementation details.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top