Chironex
Chironex

Reputation: 413

Symmetric Bandstop Filter in Matlab?

I'm using Matlab to find effective ways of deconvolving the output of a spectrometer to get the original input. The function deconvwnr() works well, except it introduces a lot of sinusoidal-esque noise which I have been getting rid of with matlab's built-in band-stop butterworth filtering:

[b,a] = butter(3,[iters-freq,iters+freq],'stop'); recovered = filter(b,a,toBS);

The problem is that this filter is one-sided, defined as

If x[n] is the array and y[n] is the filtered array, f:x->y is one-sided iff y[n] = f( x[n], x[n-1], x[n-2]...)

and introduces a shift in the spectrometer peaks:

shift

Thus, I need to use a two-sided, symmetric filter. Is there an easy, built-in way to do this in Matlab?

---Alternatively---are there any really good, "it just works", noise-tolerant deconvo algorithms out there?

Upvotes: 1

Views: 784

Answers (1)

abcd
abcd

Reputation: 42225

All filters produce a "shift" or "delay" in the output by as many number of samples as the length of the filter. This is the behaviour using the filter command.

To get no delay in the output, you should filter it once forward and once backward (+shift -shift =0). This is easily implemented using the filtfilt command. The syntax is

filtfilt(b,a,toBS)

The drawback (if you really care about this) is that the effective filter order is doubled.

Upvotes: 2

Related Questions