how linear fir algorithm works?

2 views (last 30 days)
function [y,z] = fir_filt_linear_buff(b,x,z)
y = zeros(size(x));
for n=1:length(x)
z = [x(n); z(1:end-1)];
y(n) = b * z;
end
end
in this why z is used?
i dont understand the need to use z.
please help

Accepted Answer

Prabhan Purwar
Prabhan Purwar on 26 Apr 2020
Hi,
hope this example is leveraged from the following link:
The following function represents an FIR filter with a linear buffer, where b is a row vector and z is a column vector the same length as b. x represents the input signal, b represents the filter coefficients and z represents delay/buffer in the signal.
For example:
x=[1 2 3 4 5]; % Signal
b=[1 1 1 1 1]; % Filter Coefficients, kept as unity to demonstrate effect of z
z=[0 0 0 1 0]'; % Delay/buffer
y = zeros(size(x));
for n=1:length(x)
z = [x(n); z(1:end-1)];
y(n) = b * z
end
If z=[0 0 0 0 0]' (No delay) y=[1 3 6 10 15] (FIR Output) as expected
If z=[0 0 0 1 0]' (Delay of 1 at 4th col) y=[2 3 6 10 15]
If z=[0 0 1 0 0]' (Delay of 1 at 3rd col) y=[2 4 6 10 15]
if z=[0 1 0 0 0]' (Delay of 1 at 2nd col) y=[2 4 7 10 15]
if z=[1 0 0 0 0]' (Delay of 1 at 1st col) y=[2 4 7 11 15]
For more details refer to the FIR Filter Structures.
Hope it helps!!

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!