0
votes

When we want to filter a signal in MATLAB using an IIR filter, we can simply pass the IIR filter structure into the filter command, along with our signal, to get a filtered signal, as so:

filteredSig = filter(iirFilterStruct, signal);

Let us say we wanted to filter half our signal first, then the other half, in this case we turn the 'persistent memory' flag of the iirFilterStruct on, and can perform the following:

iirFilterStruct.PersistentMemory = 1;
filteredSigFirstHalf = filter(iirFilterStruct, signal(1:Nsignal/2))
filteredSigSecondHalf = filter(iirFilterStruct, signal((Nsignal/2)+1:end)

This will give us the same result.

My question: I want to be able to extract the filter state, at some arbitrary location during the filtering operation. For example, let us say we were filtering the full signal. At location, say, Nsignal/3, I want to save the IIR filter state, and then later on, USE that state.

How can I do that?

1

1 Answers

1
votes

I assume by "iirFilterStruct" you are referring to the filter objects in MATLAB. If you are using the filter object which has the PersistentMemory it also has a method called getstates that will return the current state of the filter. You will have to call filter method up to the number of samples where you want to save state and then call getstates(iirFilterStruct) to get the state.