How to implement a generic 'filter' function using direct form I?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
vinicius lanziotti
am 14 Jun. 2019
Beantwortet: Walter Roberson
am 14 Jun. 2019
I need a code for the filter function in direct form I, like as I implemented a filter function in direct form II transposed below:
function[y] = filtro(a,b,x)
% Generic filter function in direct form II transposed
N = size(b,2) - 1;% filter order
y = zeros(size(x)); % Initializes y with zeros
%% FOR THE CASE FIR
if not(size(a,2) == size(b,2))
a(1) = 1;
a = zeros(size(b));
end
%% Recursive implementation of equations to differences
aux = zeros(1,N);
for r = 1 :size(x,2)
y(r) = b(1)*x(r) + aux(1);
for n = 2 : N
aux(n-1) = b(n)*x(r) + aux(n);
aux(n-1) = aux(n-1)- a(n)*y(r);
end
aux(N) = b(N+1)*x(r) - a(N+1)*y(r);
end
end % END OF FUNCTION
Thanks!
2 Kommentare
Walter Roberson
am 14 Jun. 2019
What is the difference between this question and the other one you asked about these filters?
Akzeptierte Antwort
Walter Roberson
am 14 Jun. 2019
filterdf1 = @(a,b,x) filter( dfilt.df1(a,b), x);
This is a three-argument filter function that uses direct type 1 form.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Downloads finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!