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)
N = size(b,2) - 1;
y = zeros(size(x));
if not(size(a,2) == size(b,2))
a(1) = 1;
a = zeros(size(b));
end
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
Thanks!
2 Comments
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/467020-how-to-implement-a-generic-filter-function-using-direct-form-i#comment_714645
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/467020-how-to-implement-a-generic-filter-function-using-direct-form-i#comment_714645
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/467020-how-to-implement-a-generic-filter-function-using-direct-form-i#comment_714808
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/467020-how-to-implement-a-generic-filter-function-using-direct-form-i#comment_714808
Sign in to comment.