フィルターのクリア

How to implement a generic 'filter' function using direct form I?

7 ビュー (過去 30 日間)
vinicius lanziotti
vinicius lanziotti 2019 年 6 月 14 日
回答済み: Walter Roberson 2019 年 6 月 14 日
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 件のコメント
Walter Roberson
Walter Roberson 2019 年 6 月 14 日
What is the difference between this question and the other one you asked about these filters?
vinicius lanziotti
vinicius lanziotti 2019 年 6 月 14 日
The difference is that if I use the command "edit(which('dfilt.df1'))" the function has only 2 inputs (num, den), and use others parameters already defined in Matlab, like (dfilt).
% Using edit(which('dfilt.df1'))
function Hd = df1(num,den)
Hd = dfilt.df1;
Hd.ncoeffs = [1 1];
Hd.FilterStructure = 'Direct-Form I';
Hd.tapIndex = [0 0];
if nargin>=1
Hd.Numerator = num;
end
if nargin>=2
Hd.Denominator = den;
end
But I need of 3 inputs, like the filter function. But this function was made using direct-form II transposed, and I want the direct-form I from function "filter". And no one parameters already defined in Matlab.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2019 年 6 月 14 日
filterdf1 = @(a,b,x) filter( dfilt.df1(a,b), x);
This is a three-argument filter function that uses direct type 1 form.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStatistics and Linear Algebra についてさらに検索

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by