请解释这段M代码的作用:close all;clear;clc; sig=load('ecg_60hz_200.dat'); N=length(sig); fs=200; t=[0:N-1]/fs; figure(1);subplot(4,2,1);plot(sig) title('Original Signal') %% % Low Pass Filter b=1/32*[1 0 0 0 0 0 -2 0 0 0 0 0 1]; a=[1 -2 1]; sigL=filter(b,a,sig); subplot(4,2,3);plot(sigL) title('Low Pass Filter') subplot(4,2,4);zplane(b,a) %% % High Pass Filter b=[-1/32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1/32]; a=[1 -1]; sigH=filter(b,a,sigL); subplot(4,2,5);plot(sigH) title('High Pass Filter') subplot(4,2,6);zplane(b,a) %% % Derivative Base Filter b=[1/4 1/8 0 -1/8 -1/4]; a=[1]; sigD=filter(b,a,sigH); subplot(4,2,7);plot(sigD) title('Derivative Base Filter') subplot(4,2,8);zplane(b,a) %% % be tavane 2 miresanim sigD2=sigD.^2; %% % normalization signorm=sigD2/max(abs(sigD2)); %% h=ones(1,31)/31; sigAV=conv(signorm,h); sigAV=sigAV(15+[1:N]); sigAV=sigAV/max(abs(sigAV)); figure(2);plot(sigAV) title('Moving Average filter') %% treshold=mean(sigAV); P_G= (sigAV>0.01); figure(3);plot(P_G) title('treshold Signal') figure;plot(sigL) %% difsig=diff(P_G); left=find(difsig==1); raight=find(difsig==-1); %% % run cancel delay % 6 sample delay because of LowPass filtering % 16 sample delay because of HighPass filtering left=left-(6+16); raight=raight-(6+16); %% % P-QRS-t for i=1:length(left); [R_A(i) R_t(i)]=max(sigL(left(i):raight(i))); R_t(i)=R_t(i)-1+left(i) %add offset [Q_A(i) Q_t(i)]=min(sigL(left(i):R_t(i))); Q_t(i)=Q_t(i)-1+left(i) [S_A(i) S_t(i)]=min(sigL(left(i):raight(i))); S_t(i)=S_t(i)-1+left(i) [P_A(i) P_t(i)]=max(sigL(left(i):Q_t(i))); P_t(i)=P_t(i)-1+left(i) [T_A(i) T_t(i)]=max(sigL(S_t(i):raight(i))); T_t(i)=T_t(i)-1+left(i)+47 end %% figure;plot(t,sigL,t(Q_t),Q_A,'*g',t(S_t),S_A,'^k',t(R_t),R_A,'ob',t(P_t),P_A,'+b',t(T_t),T_A,'+r'); for i=1:((length(P_t))-1) HRV=P_t(i+1)-P_t(i) end
时间: 2023-08-06 15:08:34 浏览: 103
LDPC-PEG算法构造H矩阵.rar_All Clear_Density Evolution_LDPC_PEG法构造H矩阵_密
5星 · 资源好评率100%
这段代码的作用是对心电图(ECG)信号进行预处理和特征提取。首先,使用一个低通滤波器、高通滤波器和导数基滤波器对原始信号进行滤波和降噪处理。然后,通过对滤波后的信号进行平方和归一化处理,得到一个移动平均滤波后的信号。接着,使用一个阈值来判断信号中的QRS波群,并提取出P、Q、R、S、T波峰的位置和幅值。最后,计算相邻P波峰之间的心率变异性(HRV)。
阅读全文