You are on page 1of 3

Experiment No.

5
Aim: Write a program to find the response of given exponential signal using
convolution without using conv() function
Code for Convolution
close all
clear all

t = 0:10 ;
h = [ones(1,11)] ;
a = length(h) ;
figure(1)
stem(t,h), title('Impulse Response') ;

t1 = 0:10 ;
x = exp(t1) ;
b = length(x) ;
figure(2)
stem(t1,x), title('Exponential Signal') ;

r = zeros(a+b-1) ;
for n=1:(a+b-1)
for k=1:b
if (n-k+1>0)&&(n-k+1<=b)
r(n)= r(n) + x(k).*h(n-k+1);
end
end
end

z = (min(t)+min(t1)):(max(t)+max(t1)) ;
figure(3)
stem(z,r), title('Convolution Signal') ;

% Verification Using conv() function


i = conv(h,x);
figure(4)
stem(z,i), title('Verification Using Conv() function') ;

You might also like