How do filter function work?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Treant
el 26 de Ag. de 2012
Editada: Sergio Cuadros
el 18 de Jun. de 2020
I understand how the filter(b,a,X) works. What confuses me is the function with the initial conditions. The function filter(b,a,X,zi).
for example: y(n)=-0.5y(n-1)+x(n) x(n)=u(n) y(-1)=1
how will the filter function solve this? i tried to do it manually, but i get different output.
0 comentarios
Respuesta aceptada
Honglei Chen
el 26 de Ag. de 2012
Editada: Honglei Chen
el 26 de Ag. de 2012
MATLAB's filter() function an implementation of direction form II, the detailed algorithm can be found at
For your case, you need to first figure out what the initial condition is. You can use filtic function.
e.g.,
b = 1;
a = [1 0.5];
y = filter(b,a,ones(10,1),filtic(b,a,1));
3 comentarios
Honglei Chen
el 27 de Ag. de 2012
It basically perform a reverse filtering operation. If you want the details, you can look at filtic code.
Sergio Cuadros
el 18 de Jun. de 2020
Editada: Sergio Cuadros
el 18 de Jun. de 2020
Hello Mr. Honglei, Could you check my question. I have a issue.
Best regards.
Más respuestas (1)
Jan
el 27 de Ag. de 2012
Editada: Jan
el 27 de Ag. de 2012
You find a Matlab implementation of the FILTER command at Answers: hard-code-filter. This should reveal the meaning of the initial and final conditions.
Splitting a signal into parts might be helpful also:
signal = rand(1,1000);
[b,a] = butter(3, 0.5); % Arbitrary filter parameters
inital_cond1 = zeros(1, length(a) - 1);
[filtered1, final_cond1] = filter(b, a, signal(1:500), initial_cond1);
[filtered2, final_cond2] = filter(b, a, signal(501:1000), final_cond1);
Joined = [filtered1, filtered2];
% Now filter in one step:
OnePiece = filter(b, a, signal, initial_cond1);
% Compare the results - should be tiny:
disp(mean(abs(Joined - OnePiece)));
This shows, that the inital conditions are the values of the internal status of the filter. When the signal is split into pieces, the final conditions of the former part are the inital conditions of the current part.
0 comentarios
Ver también
Categorías
Más información sobre Matched Filter and Ambiguity Function en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!