[数字信号处理]IIR高通滤波器加速收敛算法实现
2019-07-13 19:09发布
生成海报
clc;clear all;close all;
% 原信号
sample_rate = 100;
n = 5000;
x = 1:1:n;
data = 50000 + 1000*sin((x/sample_rate)*2*pi);
% matlab 慢收敛方法高通滤波
[b,a] = butter(2,0.33/50,'high');
data_fil_matlab = filter(b,a,data);
% 加速收敛方法
y_buff = zeros(1,3);x_buff = zeros(1,3);
data_fil_accelerate = zeros(n,1);
for data_index = 1:1:n
%滤波器
if(data_index==1)
x_buff(1) = data(data_index);
x_buff(2) = data(data_index);
x_buff(3) = data(data_index);
end
%IIR HP*******************************************************************
y_buff(1) = y_buff(2);y_buff(2) = y_buff(3);
x_buff(1) = x_buff(2);x_buff(2) = x_buff(3);
%赋值
x_buff(3) = data(data_index);
y_buff(3) = (-1)*a(2)*y_buff(2)+(-1)*a(3)*y_buff(1)+...
b(1)*x_buff(3)+b(2)*x_buff(2)+b(3)*x_buff(1);
data_fil_accelerate(data_index) = y_buff(3);
end
figure(1);
subplot(3,1,1);
plot(data);
title('Original Data');grid on;
subplot(3,1,2);
plot(data_fil_matlab);
title('Matlab Method Data');grid on;
subplot(3,1,3);
plot(data_fil_accelerate);
title('Accelerate Method Data');grid on;
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮