pxx,fx\] = pwelch(xn,\[\],\[\],\[\],Fs);
plotEKGPSD(fx,pxx,' :: Before Filtering');
%% Design a Lowpass IIR Filter
N = 7;
Fp = 75;
Ap = 1;
h = fdesign.lowpass('N,Fp,Ap', N, Fp, Ap, Fs);
d = design(h, 'cheby1');
%% Apply the filter to to Smooth out the EKG Signal
xfilter = filter(d,xn);
%% Visualize PSD of the EKG signal before and after Filtering
\[pff,ff\] = pwelch(xfilter,\[\],\[\],\[\],Fs);
plotEKGPSD(fx,pxx,'compare', ff,pff);
%% Overlay the filtered signal on the original EKG signal.
% Filtered signal is delayed
figure;
plot(tn, xn, 'b',tn, xfilter,'r');
grid on;
legend({'Original Signal','Filtered Signal'});
set(gcf,'NumberTitle','Off', 'Name','Filtered Signal vs. Actual Signal');
%% Compare the original EKG signal, filtered signal and delay compensated filtered signal
xfiltfilt = filtfilt(d.sosMatrix,d.ScaleValues, xn);
delayCompensationPlot(tn, xn, xfilter,xfiltfilt);
## ****🎉3**** ****参考文献****
> 文章中一些内容引自网络,会注明出处或引用为参考文献,难免有未尽之处,如有不妥,请随时联系删除。
\[1\]徐超逸.简单整系数滤波器在实时心电信号处理中的应用探究\[J\].电子世界, 2021(15):2.
\[2\]王光宇.基于FIR与相位补偿IIR滤波器的雷达回波信号处理\[J\].无线互联科技, 2020, 17(3):3.DOI:CNKI:SUN:WXHK.0.2020-03-004.
\[3\]周春瑜,曹鸣.基于FIR滤波器的心电图信号矫正\[J\].科协论坛:下半月, 2009(2):2.DOI:10.3969/j.issn.1007-3973.2009.02.057.
\[4\]任燕,郭仓库.基于滤波器的ECG信号预处理\[J\].电气传动自动化, 2016(3):3.DOI:CNKI:SUN:DQCD.0.2016-03-015.
## [🌈](https://mp.weixin.qq.com/mp/appmsgalbum?__biz=Mzk0MDMzNzYwOA==&action=getalbum&album_id=2591810113208958977#wechat_redirect "🌈")****4 Matlab代码实现****