Basic representations for digital signals and systems

Par J.-F. Bercher -- march 5, 2014

This lab is an elementary introduction to the analysis of a filtering operation. In particular, we will illustrate the notions of impulse response, convolution, frequency representation transfer function.

In these exercises, we will work with digital signals. Experiments will be done with Python.

We will work with the filtering operation described by the following difference equation $$ y(n)=a y(n-1) + x(n) $$ where $x(n)$ is the filter's input and $y(n)$ its output.

Study in the time domain

  1. Compute analytically the impuse response (IR), as a function of the parameter $a$, assuming that the system is causal and that the initial conditions are zero.
  2. Under Python, look at the help of function lfilter, by help(lfilter) and try to understand how it works. Propose a method for computing numerically the impulse response. Then, check graphically the impulse response, with $a = 0.8$. The following Dirac function enables to generate a Dirac impulse in discrete time:

     def dirac(n):
     """ dirac(n): returns a Dirac impulse on N points"""
     d=zeros(n); d[0]=1
     return d
  3. Compute and plot the impulse responses for $a=-0.8$, $a=0.99$, and $a=1.01$. Conclusions.

Study in the fequency domain

  1. Give the expression of the transfer function $H(f)$, and of its modulus $|H(f)|$ for any $a$. Give the theoretical amplitudes at $f = 0$ and $f = 1/2$ (in normalized frequencies, i.e. normalized with respect to Fe. Compute numerically the transfer function as the Fourier transform of the impulse response, for $a = 0.8$ and $a = -0.8$, and plot the results. Conclusions.

Filtering

  1. Create a sine wave $x$ of frequency $f0 = 3$, sampled at $Fe = 32$ on $N=128$ points

  2. Filter this sine wave by the previous filter

    – using the function filter, y1=lfilter([1],[1 -0.8],x);

    – using a convolution, y2=lfilter(h,1,x); with $h$ the impulse response of the filter for $a = 0.8$ Explain why this last operation effectively corresponds to a convolution. Compare the two results.

  3. Plot the transfer function and the Fourier transform of the sine wave. What will be the result of the product? Measure the gain and phase of the transfer function at the frequency of the sinusoid ($f_0=3$). Compare these values to the values of gain and phase measured in the time domain.

  4. Do this experiment again, but with a pulse train instead of a sine. This is done simply in order to illustrate the fact that this time, the output of the filter is deformed. You may use

     def rectpulse(x):
         """rectpulse(x): 
         Returns a pulse train with period  2pi"""
         return sign(sin(x))