2

I have some confusion about the terminologies and simulation of an FIR system. I shall appreciate help in rectifying my mistakes and informing what is correct.

Assuming a FIR filter with coefficient array A=[1,c2,c3,c4]. The number of elements are L so the length of the filter L but the order is L-1.

Confusion1: Is the intercept 1 considered as a coefficient? Is it always 1?

Confusion2: Is my understanding correct that for the given example the length L= 4 and order=3?

Confusion3: Mathematically, I can write it as:

x[n] = \sum_{l=0}^{L-1}A_l u[n-l]

where u is the input data and l starts from zero. Then to simulate the above equation I have done the following convolution. Is it correct?:

N =100; %number of data
A = [1, 0.1, -0.5, 0.62];
u = rand(1,N);
x(1) = 0.0;
x(2) = 0.0;
x(3) = 0.0;
x(4) = 0.0;
for n = 5:N
    x(n) = A(1)*u(n) + A(2)*u(n-1)+ A(3)*u(n-3)+ A(4)*u(n-4);
end
Sardar Usama
  • 19,536
  • 9
  • 36
  • 58
Srishti M
  • 533
  • 4
  • 21

1 Answers1

1

Confusion1: Is the intercept 1 considered as a coefficient? Is it always 1?

Yes it is considered a coefficient, and no it isn't always 1. It is very common to include a global scaling factor in the coefficient array by multiplying all the coefficients (i.e. scaling the input or output of a filter with coefficients [1,c1,c2,c2] by K is equivalent to using a filter with coefficients [K,K*c1,K*c2,K*c3]). Also note that many FIR filter design techniques generate coefficients whose amplitude peaks near the middle of the coefficient array and taper off at the start and end.

Confusion2: Is my understanding correct that for the given example the length L= 4 and order = 3?

Yes, that is correct

Confusion3: [...] Then to simulate the above equation I have done the following convolution. Is it correct? [...]

Almost, but not quite. Here are the few things that you need to fix.

  1. In the main for loop, applying the formula you would increment the index of A and decrement the index of u by 1 for each term, so you would actually get x(n) = A(1)*u(n) + A(2)*u(n-1)+ A(3)*u(n-2)+ A(4)*u(n-3)
  2. You can actually start this loop at n=4
  3. The first few outputs should still be using the formula, but dropping the terms u(n-k) for which n-k would be less than 1. So, for x(3) you'd be dropping 1 term, for x(2) you'd be dropping 2 terms and for x(1) you'd be dropping 3 terms.

The modified code would look like the following:

x(1)=A(1)*u(1);
x(2)=A(1)*u(2) + A(2)*u(1);
x(3)=A(1)*u(3) + A(2)*u(2) + A(3)*u(1);
for n = 4:N
  x(n) = A(1)*u(n) + A(2)*u(n-1)+ A(3)*u(n-2)+ A(4)*u(n-3);
end
SleuthEye
  • 14,379
  • 2
  • 32
  • 61
  • Thank you for your reply. It is very helpful. Just to confirm if I have followed your answer correctly, 1) if `h=[1,0.2,0.3]` then is the order is 2 and length is 3?(2)There is also another term known as `lag` for AR and MA models. Is order = lag? – Srishti M Nov 02 '17 at 22:16
  • 1) yes. 2) For MA, `lag = order/2` samples (aka `order/(2*Fs)` seconds if `Fs` is the sampling frequency in Hz). For others (non linear-phase MA, and AR) the relationship isn't that trivial. To quote the [linear-phase article on wikipedia](https://en.wikipedia.org/wiki/Linear_phase), "A filter with linear phase may be achieved by an FIR filter which is either symmetric or anti-symmetric." – SleuthEye Nov 03 '17 at 01:57