我正在尝试用光谱分析来分析时间序列。我正在尝试检测我的数据中的任何周期性,这些数据由记录了一周的每小时测量值组成(24 *7= 168个测量值),我的目标是显示温度变化的日分量。到目前为止,我有(举个例子):
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));我将从这里走向何方?任何建议都将不胜感激。
修改后的:
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');有人能建议我如何将x轴转换为小时数而不是每小时循环数吗?我试过了
plot(1./F,10*log10(Pxx)); xlabel('hours');但这搞乱了周围图。
发布于 2012-06-28 16:56:09
您可能会发现,使用MATLAB的periodogram函数比直接使用FFT更容易。它负责为您设置数据窗口以及各种其他实现细节。
https://stackoverflow.com/questions/11241125
复制相似问题