MATLAB Answers

Simulating a FIR filter

16 ビュー (過去 30 日間)
Rafael Ludtke
Rafael Ludtke 2019 年 6 月 19 日
コメント済み: Rafael Ludtke 2019 年 6 月 19 日
Hi,
I've found a lot of examples of how to use the fir1 function to calculate the FIR filter coeficients, but I need to define a input vector of samples, the coeficients and need as return the output vector.
I was able to use the filter function to simulate one sample, but I believe I should combine that with a conv function.
This is the diagram I need to simulate:
Where: x[n] is my input vector.
b[ tap_num ] is the coeficient vector.
y[n] is the output vector.
The "triangle" would be a multiplier between the input and b[ tap_num ];
As example, in a 5 tap filter, using an input like x = [ 0 0 0 1 1 1 1 1 ], and b = [ 1 1 1 1 1 ], the expected would be y = [ 1 2 3 4 5 4 3 2 ]
Whats the simpliest way to define the two input vectors ( x[n] and b[tap_num] ), and get an output vector?
Thank you!

  0 件のコメント

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

採用された回答

David Wilson
David Wilson 2019 年 6 月 19 日
編集済み: David Wilson 2019 年 6 月 19 日
Use the filter command. In this case your denominator, (A), coefficients are just 1.
x = [ 0 0 0 1 1 1 1 1 ]' % input
b = [ 1 1 1 1 1 ];
y = filter(b,1,x)
You will note that the solution above handles the initial conditions slightly differently than your proposed solution. However if this is important to you (hint: it shouldn't be unless this is a homework problem), then you need to use filtic to get them set to what you want.

  1 件のコメント

Rafael Ludtke
Rafael Ludtke 2019 年 6 月 19 日
The difference is because of the order I imagined the input vector would enter the filter, fixing that the output is what I was expecting.
Thank you!

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by