using namespace std;
{
int N = 400;
arma::vec b = "-0.2 -0.1 0.1 0.3 0.7";
arma::vec c = "-0.4 0.0 0.2 0.1 0.4";
int M = b.size();
arma::vec x( N, arma::fill::randn );
arma::vec y( N, arma::fill::zeros );
arma::vec d( N, arma::fill::zeros );
arma::vec z( N, arma::fill::randn );
arma::vec e( N, arma::fill::zeros );
arma::mat Wlog( M, N );
for( int n = 0; n < N; n++ )
{
if( n == 200 )
d( n ) = G( x( n ) ) + 0.0001 * z( n );
}
for( int n = 0; n < N; n++ )
{
y( n ) = Ghat( x( n ) );
e( n ) = d( n ) - y( n );
}
cout << "Filter coeffs: " << c.t() << endl;
cout <<
"Estimated coeffs: " << Ghat.
get_coeffs().t() << endl;
gp0.
window(
"Plot", 10, 10, 500, 500 );
gp1.
window(
"Plot2", 600, 10, 500, 500 );
arma::vec J = 10 * log10( e % e );
return 0;
}
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.