⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fir.m

📁 一个简单的FIR滤波器实现编程
💻 M
字号:
fs=50;
fp=30;
Fs=200;
M=512;
rf=(fs-fp)/Fs;
N=3.3/rf;
if mod(N,2)==0 
   NN=N;
else
   NN=N-1;
end
wp=2*pi*fp/Fs;
wc=wp;
for n=1:N
   hd(n)=(sin((n-M/2)*wc))/(pi*(n-M/2));
end
figure(2);
subplot(221);
plot(hd);
title('移位后的理想滤波器图');
for n=1:N
  hn(n)=(sin((n-NN/2)*wc))/(pi*(n-NN/2))*(0.54-0.46*cos((2*pi*n)/(N-1)));
end
subplot(222);
plot(hn);
title('加汉明窗后的滤波器图');

%对心电信号进行滤波
load BBB.txt
subplot(223);
plot(BBB);
title('原心电信号图');
for n=1:M
   sm=0;
  for i=1:M
    if (n-i)<=0||(n-i)>=N hn=0;
    else
        hn=(sin(((n-i)-NN/2)*wc))/(pi*((n-i)-NN/2))*(0.54-0.46*cos((2*pi*(n-i))/(N-1)));
    end
    sm=BBB(i)*hn+sm;
  end
  y(n)=sm;
end
subplot(224);
plot(y);
title('滤波后的心电图');

 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -