附:心电图信号抽样序列x(n)
人体心电图信号在测量过程中往往受到工业高频干扰,所以必须经过低通滤波处理后,才能作为判断心脏功能的有用信息。下面给出一实际心电图信号抽样序列样本x(n),其中存在高频干扰。在实验中,以x(n)作为输入序列,滤除其中的干扰成分。
x(n)={-4, -2, 0, -4, -6, -4, -2, -4, -6, -6,
-4, -4, -6, -6, -2, 6, 12, 8, 0, -16,
-38,-60, -84, -90, -66, -32, -4, -2, -4, 8,
12, 12, 10, 6, 6, 6, 4, 0, 0, 0,
0, 0, -2, -4, 0, 0, 0, -2, -2, 0,
0, -2, -2, -2, -2, 0}
从 s s s域映射到正切 t a n tan tan,再从 t a n tan tan映射到 z z z域
s = 2 T ⋅ 1 − z − 1 1 + z − 1 j Ω = 2 T j t a n ω 2 ( s = j Ω ) z = 1 + s T / 2 1 − s T / 2 ( s = δ + j Ω ) s=\frac{2}{T}\cdot\frac{1-z^{-1}}{1+z^{-1}}\\ j\Omega=\frac{2}{T}jtan\frac{\omega}{2}~~(s=j\Omega)\\ z=\frac{1+sT/2}{1-sT/2}~~(s=\delta+j\Omega) s=T2⋅1+z−11−z−1jΩ=T2jtan2ω (s=jΩ)z=1−sT/21+sT/2 (s=δ+jΩ)
x 0 ( t ) → H 1 ( s ) → x ( t ) → 抽 样 / 量 化 → x ( n ) → H ( z ) → y ( n ) → y s ( t ) → H 2 ( s ) → y ( t ) x_0(t)\rightarrow H_1(s)\rightarrow x(t)\rightarrow 抽样/量化\rightarrow \\ x(n)\rightarrow H(z)\rightarrow y(n)\rightarrow y_s(t)\rightarrow \\ H_2(s)\rightarrow y(t) x0(t)→H1(s)→x(t)→抽样/量化→x(n)→H(z)→y(n)→ys(t)→H2(s)→y(t)
x=[-4 -2 0 -4 -6 -4 -2 -4 -6 -6 -4 -4 -6 -6 -2 6 12 8 0 -16 -38 -60 -84 -90 -66 -32 -4 -2 -4 8 12 12 10 6 6 6 4 0 0 0 0 0 -2 4 0 0 0 -2 -2 0 0 -2 -2 -2 -2 0];
n=length(x);
xk=fft(x);
plot(0:n-1,abs(xk));
title('频域信号');
%数字滤波器指标
wp = 0.2*pi;ws = 0.3*pi;rp = 1;rs = 15;Fs = 1;
%转换成模拟域
wp1=2*Fs*tan(wp/2);
ws1=2*Fs*tan(ws/2);
[N,Wn] = buttord(wp1,ws1,rp,rs,'s');
[Z,P,K] = buttap(N);
[Bap,Aap] = zp2tf(Z,P,K);
[b,a] = lp2lp(Bap,Aap,Wn);
[bz,az] = bilinear(b,a,Fs);
[H,W] = freqz(bz,az);
disp(bz);
disp(az);
plot(W*Fs/pi,abs(H));
grid on;
xlabel('频率/Hz');
ylabel('幅度');
title('数字滤波器的频率响应');
clear;
% 读取原始数据,这里是 n * 1 的数据
Signal = [-4 -2 0 -4 -6 -4 -2 -4 -6 -6 -4 -4 -6 -6 -2 6 12 8 0 -16 -38 -60 -84 -90 -66 -32 -4 -2 -4 8 12 12 10 6 6 6 4 0 0 0 0 0 -2 4 0 0 0 -2 -2 0 0 -2 -2 -2 -2 0];
%指标
wp = 0.2*pi;ws = 0.3*pi;rp = 1;rs = 15;Fs = 1;
%计算
wp1=2*Fs*tan(wp/2);
ws1=2*Fs*tan(ws/2);
[N,Wn] = buttord(wp1,ws1,rp,rs,'s');
[Z,P,K] = buttap(N);
[Bap,Aap] = zp2tf(Z,P,K);
[b,a] = lp2lp(Bap,Aap,Wn);
[bz,az] = bilinear(b,a,Fs);
% 滤波
Signal_Filter = filter(bz, az, Signal);
subplot(2, 1, 1);
plot(Signal);
title('原始图像');
subplot(2,1,2);
plot(Signal_Filter);
title('巴特沃斯低通滤波后图像');