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);
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++)
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 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 plot_show(void)
Show plots.
void plot_add_mat(const arma::mat &y)
Push multiple plot, each row gives a plot without label.
void set_term(const char *ttype)
Set output terminal.
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.
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 set_coeffs(const arma::Mat< T2 > &_b)
Sets coefficients in FIR filter. The internal state and pointers are cleared.
void kalman_adapt(const T3 _err)
Kalman Filter update function.
void setup_kalman(const arma::uword _N, const double _P0, const double _Q0, const double _R0)
Kalman Filter function setup.