Hello everyone! I hope you all will be absolutely fine and having fun. Today, I am going to share my knowledge about how to convolve the signals using an amazing software tool, MATLAB. MATLAB is an efficient tool for signal processing. MATLAB basically works on matrices. First of all I would like to tell you a bit about the convolution. In engineering terms, convolution describes the output of the Linear Time Invariant (LTI) systems.
Convolution is basically an integral which tells us about the overlapping of one function as it is shifted over another function. Convolution and cross correlation are similar. It has a wide range of applications e.g. computer vision, probability, statistics, engineering, differential equations, signal processing etc.
Convolution in MATLAB
Here in the tutorial, Convolution in MATLAB, I will tell you that how to convolve the two signals in MATLAB using built-in command, conv. Before going into the details of this tutorial, I would like to explain you about the convolution and its mathematical form.
- You can download the MATLAB code or convolution of two signals here by clicking on the button below.
- Download .rar file, extract it and enjoy the simulation.
In simple engineering terms, convolution is used to describe the out of the Linear Time Invariant (LTI) systems (the systems which shows different response at different times). Convolution is similar to cross correlation. Input output behavior of the system can be estimated with the help of the impulse response of that system. And the output of the system can be obtained by convolving the input applied to the system and impulse response of that system.
- Suppose x(t) is the input applied to the system and h(t) is the impulse response of the system.
- Its output y(t) can be obtained using the mathematical expression given below.
y(t) = x(t)*h(t)
- In above expression * sign expresses the convolution between the input and the impulse response of the system.
- I have made a very simple block diagram representation of convolution.
- The input x(t) is applied to the system.
- The system has convolved the input x(t) and the impulse response of the system h(t) to obtain its output y(t).
- The block diagram is shown in the figure below.
- The convolution can also be represented in the form of signals.
- The figure shown below displays the convolution between input and impulse response of the system in order to obtain its output.
Source Code Description
- Just copy and paste the source code give below in your MATLAB editor to observe the convolution results.
clc %clears the command window clear all %clears the workspace t1 = 0:1:1;%time duration for the first signal t2 = 0:2:10;%time duration for the second signal f1 = 3;%frequency of the first signal f2 = 5;%frequency of the first signal x = sin(2*pi*f1.*t1);%first signal y = cos(2*pi*f2.*t2);%second signal convolution = conv(x,y) %convolution of both the signals x & y
- You can see first of all I have cleared the command window and the workspace.
- Then I have declared time duration for both the signals.
- After that I have defined the frequency for the both signals.
- Then I have defined the two different sinusoidal signals.
- At the end I have convolved both of them and removed the semicolon at the end of the statement in order to observe the results on command window in MATLAB.
- So, that was the brief description of the code, you can download it from the above button.
- The result shown on the command window are shown in the figure below.
- That was the brief discussion about how to convolve two signals in MATLAB using builtin commands conv.
So, that is all from the tutorial Convolution in MATLAB. I hope you enjoyed this tutorial. If you find any sort of problem, you can ask in comments anytime without even feeling any kind of hesitation. I will try my level best to solve your issues in a better way, if possible. In my next tutorial I will elaborate that how to declare the variables in MATLAB and how to manipulate them without assigning them with the values. I will further explore MATLAB in my later tutorials. So, till then, Take Care 🙂