資源簡(jiǎn)介
心電濾波處理的簡(jiǎn)單示例,包括hanning濾波,5點(diǎn)多項(xiàng)式擬合,1/3 fs陷波,50Hz陷波,中值濾波,求導(dǎo)算法
代碼片段和文件信息
%Bme_signal_eecgp01
fr=fopen(‘170227068820170308092718.icg‘‘r‘);
[Als]=fread(fr‘double‘);
fclose(fr);
Length=10000;%length?is?the?length?of?every?channel
for?i=1:Length
????????ecg(i)=A(5*(24000+i-1)+2);
end
%hanning濾波
N?=?length(ecg);
for?j?=?1:N-2
????y_hanning(j)?=?(ecg(j)+2*ecg(j+1)+ecg(j+2))/4;
end
y_hanning(N)=ecg(N-2);
y_hanning(N-1)=ecg(N-2);
figure(1)
subplot(211);plot(ecg);title(“orginal?ECG?signal“);
subplot(212);plot(y_hanning);title(“Hanning?濾波“);
b=[1?2?1];
a=[4];
w=0:0.001:pi;
figure(2)
freqz(baw);
title(“Hanning?濾波器頻譜特性“);
%多項(xiàng)式擬合,5點(diǎn)
for?j?=?1:N-4
????y_parbola(j)?=?(-3*ecg(j)+12*ecg(j+1)+17*ecg(j+2)+12*ecg(j+3)-3*ecg(j+4))/35;
end
figure(3)
subplot(211);plot(ecg);title(“orginal?ECG?signal“);
subplot(212);plot(y_parbola);title(“5點(diǎn)多項(xiàng)式擬合濾波“);
b1=[-3?12?17?12?-3];
a1=[35];
figure(4)
freqz(b1a1w);
title(“多項(xiàng)式擬合濾波器幅頻特性“)
%1/3?fs陷波器
ecg=y_hanning;%處理目標(biāo)信號(hào)
fs?=?1000;
f=1/3*1000;
t=1/fs:1/fs:10;
x=sin(2*pi*f*t);%1/3fs正弦波
sig_noise=ecg+x;
for?j?=?3:N
????y_trapper(j)=(ecg(j)+ecg(j-1)+ecg(j-2))/3;
end
figure(5)
subplot(411);plot(ecg);title(“orginal?ECG?signal“);
subplot(412);plot(x);title(“noise?signal“);
subplot(413);plot(sig_noise);title(“noise?and?oringinal?signal“);
subplot(414);plot(y_trapper);title(“1/3?fs?trap?signal“);
figure(6)
b2=[1?1?1];
a2=[3];
freqz(b2a2w);
title(“1/3?fs陷波器幅頻特性“);
%50Hz數(shù)字濾波器
fs=1000;
f=50;%陷波頻率
downsample=fs/(3*f);%降采樣選擇
downsig=ecg(1:downsample:10000);%降采樣后信號(hào)
t=1/(fs/downsample):1/(fs/downsample):10;
x=sin(2*pi*50*t);%50Hz正弦信號(hào)
sig_50=downsig+x;%添加噪聲
for?i=3:length(sig_50)
y_com(i)=1/3*(sig_50(i)+sig_50(i-1)+sig_50(i-2));
end
figure(7)
subplot(411);plot(downsig);title(“orginal?ECG?signal“
評(píng)論
共有 條評(píng)論