Is there a function like "y = filter(b,a,x,zi) uses initial conditions zi for the filter delays" in fftfilt? If not, what's the most efficient way to implement this?
15 views (last 30 days)
Show older comments
Is there anything like "y = filter(b,a,x,zi) uses initial conditions zi for the filter delays" in fftfilt? If not, what's the most efficient way to implement this by using fftfilt.
Thanks a lot! Every answer helps.
Paul on 16 Apr 2022
Edited: Paul on 17 Apr 2022
Filtering is a linear operation so the iniital condition response and the input response can be computed separately and then added together. filter() uses a Direct-Form II Tranposed realization. The initial condition response of the filter can be determined from the system and output matrices of that realization.
Generate an IIR filtr
b = rand(1,5);
a = [1 rand(1,4)]
The A-matrix and C-matrix of the DFIIT realization is
A = diag(ones(1,3),1);
A(:,1) = -a(2:end).';
C = zeros(1,size(A,1)); C(1) = 1;
Verify the characteristic polynomial
Initial conditions for the taps
xi = 1:4;
Generate the 10 samples of the IC response using filter()
y1 = filter(b,a,zeros(1,10),xi);
Generate the IC response from the realization (could probalby be done more efficiently)
for n = 0:9
y2(n+1) = C*(A^n)*xi(:);
However, the Question asks about using fftfilt(), which implies the underlying filter is a FIR filter. In this case, the initial condition response DFIIT filter is simply xi followed by zeros, which can be seen by inspection of the DFIIT realization.
y3 = filter(b,1,zeros(1,10),xi)
So if we want to use fftfiltt() instead of filter() with initial conditions for a DFIIT realization:
u = rand(1,10); % random intput
y4 = filter(b,1,u,xi);
y5 = fftfilt(b,u) + [xi zeros(1,numel(u)-numel(xi))];
y4 - y5
More Answers (0)
Find more on Filter Design in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!