MATLAB code for continuous time convolution

Course Details

Field of Study: Electronics Engineering
Course Name: Signals and Systems
Description: MATLAB code for continuous time convolution when x(t)=u(t-3)-u(t-5) and h(t)=u(t)exp(-3t)

What is Continuous time convolution?
Continuous time convolution is an operation on two continuous time signals defined by the integral:
(xh)(t)= int(x(tau)h(t-tau),tau,-inf,inf)
for all x,h defined on R.

It is unlike discrete time convolution and the MATLAB conv command is not used to compute continuous time convolution.
Instead we have to use the convolution integral in the MATLAB code.
In this specific continuous time convolution MATLAB code, the input signal to the LTI system and system’s impulse response are given below:
x(t)=u(t-3)-u(t-5) – input signal to the LTI system
h(t)=u(t)exp(-3t) – system’s impulse response
Then the output of the LTI system is the convolution integral of the input signal, x(t) and system’s impulse response, h(t).

MATLAB Code
clc;
clear all;
close all;
syms t tau % Short-cut for constructing symbolic objects.
x = heaviside(t-3)-heaviside(t-5); % input signal to the LTI system
h = exp(-3t)heaviside(t); % system’s impulse response
y=int(subs(x,tau)subs(h,t-tau),tau,0,t);
disp(‘The output of the convolution integral is’);
disp(y);
subplot(3,1,1);
ezplot(x,[0,10]);
title(‘Input signal for LTI system’);
xlabel(‘t’)
ylabel(‘x(t)’)
grid;
subplot(3,1,2);
ezplot(h);
title(‘LTI System impulse response’);
xlabel(‘t’)
ylabel(‘h(t)’)
grid;
ti = 0;
tf = 10;
N = 1000;
dt = (tf-ti)/N;
t = ti:dt:tf;
x = heaviside(t-3)-heaviside(t-5);
x=x
dt;
if t>=0
h = exp(-3*t);
else
h=0;
end
y1=conv(x,h);
subplot(3,1,3);
plot(t, y1 (1: length (t)));
title(‘Output of LTI system’);
xlabel(‘t’)
ylabel(‘y(t)’)
grid;

The MATLAB plot for the input signal, x(t), inpulse response, h(t) and output, y(t) is shown below
CT_Convolution

Share this article:
Previous Post: MATLAB code to prepare database of n students for 5 subjects

December 2, 2014 - In Academics, Electronics

Next Post: Stepper motor interfacing with 8086 microprocessor

December 4, 2014 - In Academics, Computers

Related Posts

Leave a Reply

Your email address will not be published.