使用频率分析求周期性

        通常很难通过观察时间测量值来表征数据中的振荡行为。频谱分析有助于确定信号是否为周期性信号并测量不同周期。

        办公楼内的温度计每半小时测量一次室内温度,持续四个月。加载数据并对其绘图。将温度转换为摄氏度。测量时间以周为单位。因此,采样率为 2 次测量/小时 × 24 小时/天 × 7 天/周 = 336 次测量/周。

load officetemp

tempC = (temp - 32)*5/9;

fs = 2*24*7;
t = (0:length(tempC) - 1)/fs;

plot(t,tempC)
xlabel('Time (weeks)')
ylabel('Temperature ( {}^\circC )')
axis tight

如图所示:

Figure contains an axes object. The axes object with xlabel Time (weeks), ylabel Temperature ( blank toThePowerOf degree baseline C blank ) contains an object of type line.

        温度似乎确实有震荡特性,但周期的长度并不容易确定。此时,看看信号的频率成分。

        减去均值以重点关注温度波动。计算并绘制周期图。

tempnorm = tempC - mean(tempC);

[pxx,f] = periodogram(tempnorm,[],[],fs);

plot(f,pxx)
ax = gca;
ax.XLim = [0 10];
xlabel('Frequency (cycles/week)')
ylabel('Magnitude')

如图所示:

Figure contains an axes object. The axes object with xlabel Frequency (cycles/week), ylabel Magnitude contains an object of type line.

        温度显然有日周期和周周期。结果并不令人惊讶:在人们工作时温度较高,晚上和周末温度较低。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值