2
$\begingroup$

I am have data in 1 minute chunks but I would like perform filtering on these as if the data was one contiguous signal. How might I hold the filters state between processing data chunks to achieve this.

I am using an FIR in MATLAB with the filter() function.

$\endgroup$

2 Answers 2

1
$\begingroup$

You can use the filter function of matlab with initial conditions with the following syntax: (excerpted from Matlab 6.0 command window help)

[Y,Zf] = FILTER(B,A,X,Zi) gives access to initial and final conditions, Zi
and Zf, of the delays.  Zi is a vector of length MAX(LENGTH(A),LENGTH(B))-1
or an array of such vectors, one for each column of X.

Hope this helps.

$\endgroup$
1
  • 1
    $\begingroup$ I didn't realise it was built in, fantastic. I was thinking of more esoteric ways to try and handle this. Thanks $\endgroup$ Commented Nov 9, 2016 at 20:28
1
$\begingroup$

the filter function has the parameter zi for the initial filter state. It also returns zf, as the final filter state. Hence, you can do as follows:

% Assuming chunks contains the chunks as the columns:
zi = 0;
for c = 1:size(chunks,2)
  [y, zi] = filter(..., zi);
end

Then, the filter state is retained between the calls. However, you need to take care that you need to perform overlap and add of the returned sequences y.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.