利用Matlab工具箱设计FIR和IIR滤波器

2023-09-26

SOS Matrix:
1 2 1 1 -1.9483812279206605 0.95235504547143668
1 2 1 1 -1.8848795046449112 0.88872380736622714
Scale Values:
0.0009934543876940359
0.00096107568032897277

截止频率:75Hz

SOS Matrix:
1 2 1 1 -1.9399670771829454 0.94523778322684693
1 2 1 1 -1.867646689657416 0.8727209080865993
Scale Values:
0.0013176765109754376
0.0012685546072958092

截止频率:85Hz

SOS Matrix:
1 2 1 1 -1.9314328304904613 0.93817732047303393
1 2 1 1 -1.8505362037561721 0.85699820579506891
Scale Values:
0.001686122495643158
0.0016155005097241886

截止频率:95Hz

SOS Matrix:
1 2 1 1 -1.9227805373301849 0.93117365861042944
1 2 1 1 -1.8335462899281088 0.84154989516829737
Scale Values:
0.002098280320061078
0.0020009013100471622

截止频率:105Hz

SOS Matrix:
1 2 1 1 -1.9140122208955201 0.92422678970950123
1 2 1 1 -1.8166752155117512 0.82637032288824241
Scale Values:
0.0025536422034952134
0.0024237768441227759

生成IIR滤波器调用函数

function Hd = iir_designer
%IIR_DESIGNER Returns a discrete-time filter object.
% MATLAB Code
% Generated by MATLAB(R) 9.1 and the DSP System Toolbox 9.3.
% Generated on: 19-Aug-2023 21:26:11
% Butterworth Lowpass filter designed using FDESIGN.LOWPASS.
% All frequency values are in Hz.
Fs = 6400; % Sampling Frequency
N = 4; % Order
Fc = 65; % Cutoff Frequency
% Construct an FDESIGN object and call its BUTTER method.
h = fdesign.lowpass('N,F3dB', N, Fc, Fs);
Hd = design(h, 'butter');
% [EOF]

滤波器验证比较

%%
close all;
clc;
clear;
f = 50;
fs = 6400; %采样频率
time = 1 / fs;
t = 0:time:0.1;
y1 = sin(2 * pi * f * t) + sin(2 * pi * 13 * f * t);
figure('color',[1,1,1]);
subplot(3,1,1);
plot(t,y1);
title('滤波前波形(基波50Hz+13次谐波)');
%%
y2 = filter(fir_designer,y1); % 直接使用设计好的滤波器进行滤波,fir_designer函数是滤波

函数

subplot(3,1,2);
plot(t,y2);
title('FIR滤波后波形');
%%
y3 = filter(iir_designer,y1); % 直接使用设计好的滤波器进行滤波,iir_designer函数是滤波

函数

subplot(3,1,3);
plot(t,y3);
title('IIR滤波后波形');

文章推荐

相关推荐