24 arma::vec b =
"-0.2 -0.1 0.1 0.3 0.7";
25 arma::vec c =
"-0.4 0.0 0.2 0.1 0.4";
37 arma::vec x( N, arma::fill::randn );
38 arma::vec y( N, arma::fill::zeros );
39 arma::vec d( N, arma::fill::zeros );
40 arma::vec z( N, arma::fill::randn );
41 arma::vec e( N, arma::fill::zeros );
44 arma::mat Wlog( M, N );
47 for(
int n = 0; n < N; n++ )
51 d( n ) = G( x( n ) ) + 0.0001 * z( n );
55 for(
int n = 0; n < N; n++ )
58 y( n ) = Ghat( x( n ) );
61 e( n ) = d( n ) - y( n );
74 cout <<
"Filter coeffs: " << c.t() << endl;
75 cout <<
"Estimated coeffs: " << Ghat.
get_coeffs().t() << endl;
77 gp0.
window(
"Plot", 10, 10, 500, 500 );
83 gp1.
window(
"Plot2", 600, 10, 500, 500 );
85 arma::vec J = 10 * log10( e % e );
void nlms_adapt(const T3 _err)
NLMS Filter update function.
void update_coeffs(const arma::Mat< T2 > &_b)
Updates coefficients in FIR filter without clearing the internal states.
arma::Col< T2 > get_coeffs()
Get coefficients from FIR filter.
void setup_nlms(const arma::uword _N, const double _mu, const T2 _c, const arma::uword _L=1)
NLMS Filter function setup.
void set_coeffs(const arma::Mat< T2 > &_b)
Sets coefficients in FIR filter. The internal state and pointers are cleared.
void plot_show(void)
Show plots.
void set_term(const char *ttype)
Set output terminal.
void plot_add(const T1 &x, const T2 &y, const std::string lb, const std::string ls="lines")
Push plot y vs. x with label and linespec.
void plot_add_mat(const arma::mat &y)
Push multiple plot, each row gives a plot without label.
void window(const int fig, const char *name, const int x, const int y, const int width, const int height)
Configure the figure used Windows environment.