转自:http://user.qzone.qq.com/10809719/blog/1230648428
好的作业题目可以激起人挑战的欲望,并指引着自己学习一系列的东西。可是这样的题目并不常见,上一次见到是什么时候我已经不记得了,昨天,一道让人忍不住叫好的作业题目摆在我的面前。
先看题目,是某大学大四学生的课程作业:
-------
题目
Heart Beat Period Detection
背景交代
In clinic, it is frequently required to detect heart rate. The
heart rate is usually computed from RR-interval, which is obtained
from ECG.
However, while ECG measuring, noises are frequently
superposed.
任务
Process the noised signal to obtain ECG signal
Propose algorithm to acquire RR intervals
The Heart Rate is calculated from averaging 10
RR-intervals
数据
The signal is given in the data file, ‘nNoiseECG.txt’, the sampling
frequency is 500Hz
要求
Finish the tasks individually and independently
Write a project report in
English. Give and explain the full processes with Matlab
programs
--------
点评一下,这个题目中一组脉冲信号被噪声所调制,噪声包含有规律的正弦信号,以及没有规律的白噪声。题目要求从被测信号,即被调制后的信号中提取出有用的脉冲信号,并分析它的周期和频率。
典型的信号处理题目,包含了频谱分析、滤波、阈值设定、选择极值点等一系列方法,采用Matlab进行解题,可以非常清楚的熟悉信号软件处理的全过程、回顾信号与系统、传感器技术等专业知识,非常有意义。
由于原始数据过大不便粘贴,这里模拟出一组数据,在Matlab命令行输入:
t=[0:0.002:5.998]';
d =
0:1/1.8:6;
nNoiseECG=sin(2*pi*0.24*t)+2*pulstran(t,d,'tripuls',0.1,1)+0.1*randn(3000,1);
% 叠加正弦漂移和尖峰信号以及随机白噪声
plot(t,nNoiseECG)
xlabel('t(s)')
ylabel('Voltage(v)')
title('Original Signal')
得到原始波形,如图1所示
好的作业题目可以激起人挑战的欲望,并指引着自己学习一系列的东西。可是这样的题目并不常见,上一次见到是什么时候我已经不记得了,昨天,一道让人忍不住叫好的作业题目摆在我的面前。
先看题目,是某大学大四学生的课程作业:
-------
题目
Heart Beat Period Detection
背景交代
In clinic, it is frequently required to detect heart rate. The
heart rate is usually computed from RR-interval, which is obtained
from ECG.
However, while ECG measuring, noises are frequently
superposed.
任务
Process the noised signal to obtain ECG signal
Propose algorithm to acquire RR intervals
The Heart Rate is calculated from averaging 10
RR-intervals
数据
The signal is given in the data file, ‘nNoiseECG.txt’, the sampling
frequency is 500Hz
要求
Finish the tasks individually and independently
Write a project report in
English. Give and explain the full processes with Matlab
programs
--------
点评一下,这个题目中一组脉冲信号被噪声所调制,噪声包含有规律的正弦信号,以及没有规律的白噪声。题目要求从被测信号,即被调制后的信号中提取出有用的脉冲信号,并分析它的周期和频率。
典型的信号处理题目,包含了频谱分析、滤波、阈值设定、选择极值点等一系列方法,采用Matlab进行解题,可以非常清楚的熟悉信号软件处理的全过程、回顾信号与系统、传感器技术等专业知识,非常有意义。
由于原始数据过大不便粘贴,这里模拟出一组数据,在Matlab命令行输入:
t=[0:0.002:5.998]';
d =
0:1/1.8:6;
nNoiseECG=sin(2*pi*0.24*t)+2*pulstran(t,d,'tripuls',0.1,1)+0.1*randn(3000,1);
% 叠加正弦漂移和尖峰信号以及随机白噪声
plot(t,nNoiseECG)
xlabel('t(s)')
ylabel('Voltage(v)')
title('Original Signal')
得到原始波形,如图1所示
第二步,分析信号中的频率成分
命令行输入:
Y = fft(nNoiseECG,16384);%进行16384个点的fft变换
Pyy = Y.* conj(Y) /
16384;
f = 500*(0:8192)/16384;
plot(f,Pyy(1:8193))
title('Frequency content of y')
xlabel('frequency (Hz)')
axis([0 10 0 1500]);
grid on;
调用fdatool设计高通滤波器(命令行输入fdatool),如图3所示,下限截止频率4Hz,上限20Hz(值越大,滤波后可用的尖峰越多)。
利用M语言进行滤波
在图3所示的fdatool中File->Export,导出到Workspace中。
在命令行输入:
a=filter(Num,1,nNoiseECG);
plot(t,a) % 滤波后画图
xlabel('t(s)')
ylabel('Voltage(v)')
title('Signal After Filtering'
图形同图4
设定阈值为0.5,小于0.5的点设置为0
命令行输入:
for i=1:3000
if (a(i)<0.5)
a(i)=0;
end
end
b=find(diff(sign(diff(a)))<0)+1;%
求解极值点序号
plot(t, a,t(b), a(b),'r*') %
画出去噪声后的波形,由于滤波的关系,前一秒钟的信号异常,因此只画1s以后的数据
xlabel('t(s)')
ylabel('Voltage(v)')
axis([1 6 0 2]);
title('Final Signal')
grid on
如图5所示。图5中红色的十字叉为极值点。
根据图6,可以看到在第5,6个波峰处出现了多个极值点,因此考虑调高阈值进行去噪。设定阈值为0.85,小于0.85的点设置为0
命令行输入:
for i=1:3000
if (a(i)<0.5)
a(i)=0;
end
end
b=find(diff(sign(diff(a)))<0)+1;%
求解极值点序号
plot(t, a,t(b), a(b),'r*') %
画出去噪声后的波形,由于滤波的关系,前一秒钟的信号异常,因此只画1s以后的数据
ylabel('Voltage(v)')
axis([1 6 0 2]);
title('Final Signal')
grid on
第六步,确定RR时间间隔
取最后9个脉冲时间间隔取平均,得到RR时间间隔和频率
命令行输入:
(t(b(9))-t(b(1)))/10
10/(t(b(9))-t(b(1)))