Digital Signal Processing

Convolution in Discrete-Time – Matlab

The output y[n] of a particular LTI-system can be obtained by:

The previous equation is called Convolution between discrete-time signals x[n] and h[n].

By convention, the convolution between x[n] and h[n] is expressed as follows:

Example 1. 

Let the following rectangular pulse x[n] be an input to an LTI system with impulse response h[n]:

Determine the output y[n] of the system.


In Elementary sequences we have designed a function stepseq for plotting the unit step function in discrete time, or any combination as example 1. Next Script allows plotting x[n].

xlabel(‘n’); ylabel(‘x[n]’)

Figure 1. Input sequence x[n], example 1.

Next Script allows plotting h[n].

xlabel(‘n’); ylabel(‘h[n]’)

Figure 2. Impulse response h[n] for system in example 1.

Now, we use conv Matlab function to determine y[n]:

xlabel(‘n’); ylabel(‘y[n]’)

Figure 3. Output sequence y[n]=x[n]*h[n] for example 1.

Another approach is by using the filter function (see Solving discrete-time differential equations):

xlabel(‘n’); ylabel(‘y[n]’)

What yields:

Figure 4. Output sequence y[n]=x[n]*h[n] for example 1.

There is a difference in the outputs of these two implementations that should be noted. As you can see in Figure 3, the output sequence from conv(x,h) function has a longer length than both x[n] and h[n] sequences. On the other hand, the output sequence from the filter(h,1,x) function in Figure 4 has exactly the same length as the input x[n] sequence. In practice, the use of the filter function is encouraged.

Watch out: The filter function can be used to compute the convolution indirectly. That was possible because of the impulse response in example 1 was a one-side exponential sequence for wich we could determine a difference equation representation. Not all infinite-lenght impulse responses can be converted into difference equations.

Analytical Convolution

We can do the convolution of x[n] and h[n] Analytically:

Applying the given equation for convolution:

We now use an expression for the sum of any finite number of terms of a geometric series (The Geometric Series in DSP), and that is given by:

So, we can express equation (1) as follows:

Equation (3) is almost a geometric series sum as equation (2) except that the terms u(n-k) takes different values depending on n and k. There are three possible conditions under u(n-k) which can be evaluated:

Case 1. n<0. Then u(n-k)=0 for 0 k 9. In consequence:

Case 2. In this case the nonzero values of and do not overlap. So, for 0n<9 then u(n-k)=1 for 0kn. In consequence:

Applying formula of equation (2):

Case 3. In this case the impulse response h[n] partially overlap the input x[n]. So, for 9 n. Then u(n-k)=1 for 0 k 9. In consequence:

In this last case h[n] completely overlaps the input x[n].

Graphical method

We can also use a graphical method as in the following example.

Example 2

The input signal x[n] to an LTI system with impulse response h[n]:

Determine graphically y[n] through:

La imagen tiene un atributo ALT vacío; su nombre de archivo es null-63.png


Sequences x[k] and h[n-k], and the convolution of both signals can be seen as follows:

We can also use convolution properties as follows.

Example 3
Convolution Properties.

Other interesting properties are:

With an input x[n], the response of a LTI system y[n] is:

The impulse response h[n] of the system is:

Determine x[n]. Choose the right answer from:



We express the impulse response in terms of displaced Dirac deltas:

If we select:


So right answer is letter a). Demonstration: Using the previous equation, Let´s plot y[n] in Matlab.

The impulse response h[n] and option a) for input x[n] can be plotting in Matlab using:

xlabel(‘n’); ylabel(‘h[n]’)

Figure 5. Impulse response h[n] for system in example 3.

xlabel(‘n’); ylabel(‘x[n]’)

Figure 6. Input signal x[n] for system in example 3.

Now, y[n] can be plotting by using:


Figure 7. Output sequence y[n] for example 3.

Which we would also have been able to get by using:

La imagen tiene un atributo ALT vacío; su nombre de archivo es null-64.png

xlabel(‘n’); ylabel(‘y[n]’)

Figure 8. Output sequence y[n]=x[n]*h[n] for example 3.



  • Digital Signal Processing Using Matlab, 3erd ed
  • Fundamentos_de_Señales_y_Sistemas_usando la Web y Matlab
  • Oppenheim – Señales y Sistemas
  • Análisis de Sistemas Lineales Asistido con Scilab – Un Enfoque desde la Ingeniería Eléctrica.

Literature review by:

Prof. Larry Francis Obando – Technical Specialist – Educational Content Writer

Exercises are solved!!

WhatsApp:  +34633129287  Inmediate Attention!!

Twitter: @dademuch

Copywriting, Content Marketing, Tesis, Monografías, Paper Académicos, White Papers (Español – Inglés)

Escuela de Ingeniería Electrónica de la Universidad Simón Bolívar, USB Valle de Sartenejas.

Escuela de Ingeniería Eléctrica de la Universidad Central de Venezuela, UCV Caracas.

Escuela de Turismo de la Universidad Simón Bolívar, Núcleo Litoral.

Contacto: España. +34633129287

Caracas, Quito, Guayaquil, Jaén. 

WhatsApp:  +34633129287   

Twitter: @dademuch

FACEBOOK: DademuchConnection


11 comentarios en “Convolution in Discrete-Time – Matlab”

Deja una respuesta

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de

Estás comentando usando tu cuenta de Salir /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Salir /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Salir /  Cambiar )

Conectando a %s