How to setup a second order C++ IIR filter with Matlab

Generating parameters with Matlab

Open your matlab and type fdatool, and click “Analysis->Filter Coefficients“.

Click “Design Filter“ and get filter parameters.
Numerator: [ 1 2 1 ]
Denominator: [ 1 -1.8153410827045682 0.83100558934675761 ]
Gain: 0.0039161266605473692

Test your IIR filter

git IIR Code

1
git clone https://github.com/kaylorchen/IIR_Filter.git

Initialize your filter:

1
IIR_Filter lowpass(1, 2, 1, -1.8153410827045682, 0.83100558934675761);  // Fs = 48000, Fc=1000
0%