Skip to content

Least Squares Optimised FIR Filter

Sambit Paul edited this page Dec 2, 2023 · 2 revisions
The examples provided here use this signal:

$\cos(2\pi\times0.5t) + 0.2\sin(2\pi\times2.5t+0.1) + 0.2\sin(2\pi\times15.3t) + 0.1\sin(2\pi\times16.7t + 0.1) + 0.1\sin(2\pi\times23.45t+0.8)$

FIRLS

firls

The parameters for this filter are as follows:

  • Taps ⇨ 7
  • Bands ⇨ [0Hz, 1Hz, 2Hz, 4Hz, 4.5Hz, 5Hz]
  • Gains ⇨ [0.0, 0.0, 1.0, 1.0, 0.0, 0.0]
  • Sampling Frequency ⇨ 100Hz
Code
double samplingRate = 100;
double[] freqs = {0.0, 1.0, 2.0, 4.0, 4.5, 5.0};
double[] gains = {0.0, 0.0, 1.0, 1.0, 0.0, 0.0};
int taps = 7;

FIRLS fwls = new FIRLS(taps, samplingRate);
double[] coefficients = fwls.computeCoefficients(freqs, gains);
double[] out = fwls.firfilter(coefficients, signal);
Clone this wiki locally