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?
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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.
0 comentarios
Respuesta aceptada
Paul
el 16 de Abr. de 2022
Editada: Paul
el 17 de Abr. de 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.
For example:
Generate an IIR filtr
rng(100)
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
a
poly(A)
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(:);
end
Compare
[y1;y2]
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]
y4 - y5
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!