Output
Filter coeffs:
-0.0051 0.0134 0.1474 0.3444 0.3444 0.1474 0.0134 -0.0051
Impulse response:
-0.0051 0.0134 0.1474 0.3444 0.3444 0.1474 0.0134 -0.0051 0 0 0
*0 0 0 0
IIR theor. impulse response:
0.2500 0.7250 0.9025 0.8123 0.7310 0.6579 0.5921 0.5329 0.4796
*0.4317 0.3885 ... IIR output: 0.2500 0.7250 0.9025 0.8123 0.7310
*0.6579 0.5921 0.5329 0.4796 0.4317 0.3885 0.3496 0.3147 0.2832
*0.2549
Delay three samples:
0 0 0 0.2500 0.7250 0.9025 0.8123 0.7310 0.6579
*0.5921 0.5329 0.4796 0.4317 0.3885 0.3496
Source
using namespace arma;
{
vec b;
int N = 15;
b = fir1( 7, 0.35 );
vec X( N );
X.zeros();
X[0] = 1;
vec Y( N );
Y.zeros();
for( int n = 0; n < N; n++ )
{
Y[n] = fir_filt( X[n] );
}
std::cout << "Filter coeffs: \n" << b.t() << std::endl;
std::cout << "Impulse response:\n" << Y.t() << std::endl;
vec a;
b = { 0.25, 0.5, 0.25 };
a = { 1, -0.9 };
std::cout << "IIR theor. impulse response: \n 0.2500 0.7250 0.9025 0.8123 "
" 0.7310 0.6579 0.5921 0.5329 0.4796 0.4317 0.3885 ..."
<< std::endl;
std::cout << "IIR output: \n" << Y.t() << std::endl;
std::cout <<
"Delay three samples:\n" << del.
delay( Y ).t() << std::endl;
return 0;
}
arma::Col< T1 > delay(const arma::Col< T1 > &in)
A delay operator (vector version).
void set_coeffs(const arma::Mat< T2 > &_b)
Sets coefficients in FIR filter. The internal state and pointers are cleared.
void set_coeffs(const arma::Col< T2 > &_b, const arma::Col< T2 > &_a)
Sets coefficients in IIR filter. The internal state and pointers are cleared.
arma::Col< T3 > filter(const arma::Col< T1 > &in)
Filter function.