You are on page 1of 21

COLLEGE OF ENGINEERING, PUNE

(Electrical Engineering Department)


Signal Processing Lab
Experiment No :- 1

Title - To generate and analyze different types of analog


signals and discrete sequences.

Date of Performance – 12/09/2021

Mis No: - 142005001

Name: - Jaffer Ahmad Khan

Grade: -

Signature of Faculty: -
Theory –

Convolution Theorem

➢ It is an operation that uses multiplication and


addition.
➢ Result is a function.
➢ It is a way to combine two functions.
➢ It is like weighting one function with the other .
➢ Flipping one function then summing up the
products for each position for a given offset n.

y[n] = ··· + x[−1]h[n + 1] + x[0]h[n] + ··· + x[k]h[n − k] + ···

o This operation on the time functions or signals x[.]


and h[.] to generate a signal y[.] is called
convolution.
➢ The standard symbol for the operation of
convolution is ∗, and we use it to write the
prescription in Equation, as y[n] = (x ∗ h)[n].

o Because there will be so many Fourier transforms


in the rest of this presentation, it is useful to
introduce a shorthand notation. T will be used to
indicate a forward Fourier transform, and its
inverse to indicate the inverse Fourier transform.

o There are two ways of expressing the convolution


theorem:
✓ The Fourier transform of a convolution is the
product of the Fourier transforms.
✓ The Fourier transform of a product is the
convolution of the Fourier transforms.

o The convolution theorem is useful, in part,


because it gives us a way to simplify many
calculations. Convolutions can be very difficult to
calculate directly, but are often much easier to
calculate using Fourier transforms and
multiplication
Properties
1. Commutative Law: (Commutative Property of
Convolution)
x(n) * h(n) = h(n) * x(n)

2. Associate Law: (Associative Property of Convolution)

[ x(n) * h1(n) ] * h2(n) = x(n) * [ h1(n) * h2(n) ]

3. Distribute Law: (Distributive property of


convolution)
x(n) * [ h1(n) + h2(n)] = x(n) * h1(n) + x(n) * h2(n)
Example 2.1 -
Consider an LTI system with impulse response h[n] and input x[n], as
illustrated in Figure 2.3(a). For this case, since only x[O] and x[1] are
nonzero, eq. (2.6) simplifies to the expression y[n] = x[O]h[n- 0] +
x[1]h[n - 1] = 0.5h[n] + 2h[n- 1]. (2.8) The sequences 0.5h[n] and
2h[n- 1] are the two echoes of the impulse response needed for the
superposition involved in generating y[n]. These echoes are
displayed in Figure 2.3(b). By summing the two echoes for each value
of n, we obtain y[n], which is shown in figure.

Figure 2.3 (a) The impulse response h[n] of an LTI system and an
input x[n] to the system; (b) the responses or "echoes," 0.5h[n] and
2h[n - 1], to the nonzero values of the input, namely, x[O] = 0.5 and
x[1] = 2; (c) the overall response y[n], which is the sum of the echoes
in (b).
MATLAB code for example 2.1
clc
clear all
close all
n1=input('Enter the time sample range of x : ');
x=input('\nEnter the sequence : ');
n2=input('\nEnter the time sample range of y : ');
y=input ('\nEnter the sequence : ');
u=min(min(n1),min(n2));
t=max(max(n1),max(n2));
r=u:1:t;
z1=[];
temp=1;
for i=1:length(r)
if(r(i)<min(n1) || r(i)>max(n1))
z1=[z1 0];
else
z1=[z1 x(temp)];
temp=temp+1;
end
end
z2=[];
temp=1;
for i=1:length(r)
if(r(i)<min(n2) || r(i)>max(n2))
z2=[z2 0];
else
z2=[z2 y(temp)];
temp=temp+1;
end
end
z=z1+z2;
subplot(3,1,1);
stem(r,z1);
subplot(3,1,2);
stem(r,z2);
subplot(3,1,3);
stem(r,z);

Commands

Enter the time sample range of x :


-2:1:4

Enter the sequence :


[0 0 0.1 0.1 0.1 0 0 ]

Enter the time sample range of y :


-2:1:4

Enter the sequence :


[0 0 0 1 1 1 0]
Output: -
Example 2.2.
MATLAB code example 2.2

x=[0 0 0.5 2 0 0 0]
n=[-2 -1 0 1 2 3 4]
figure(1)
stem(n,x)

x=[1 1 1 0 0 0]
n=[-2 -1 0 1 2 3 ]
figure(2)
stem(n,x)

x=[0 1 1 1 0 0 ]
n=[-2 -1 0 1 2 3 ]
figure(3)
stem(n,x)

x=[0 0 1 1 1 0 ]
n=[-2 -1 0 1 2 3 ]
figure(3)
stem(n,x)

x=[0 0 0 1 1 1 ]
n=[-2 -1 0 1 2 3 ]
figure(4)
stem(n,x)

Output:
FIGURE 1-
FIGURE 2-
FIGURE 3-
FIGURE 4-
Example 2.3 -
MATLAB code example 2.3
t=-2:1:2;
y=[zeros(1,2), ones(1,1), zeros(1,2)];
subplot(2,2,1);
stem(t,y);
ylabel('d(n)');
xlabel('unit impulse');

n=input('\nEnter n values : ');


t=0:1:n-1;
y1=ones(1,n);
subplot(2,2,2);
stem(t,y1);
ylabel('Amplitude');
xlabel('unit step');

n=input('\nEnter n values : ');


t=0:1:n-1;
subplot(2,2,3);
stem(t,t);
ylabel('Amplitude');
xlabel('unit ramp');

n=input('\nEnter length of exponential seq : ');


t=0:1:n-1;
a=input('\nEnter a value : ');
y2=exp(a*t);
subplot(2,2,4);
stem(t,y2);
xlabel('Exponential fun');
ylabel('Amplitude');

Commands

Enter n values :
100 ////////// MIS MULTPLIED BY 100.

Enter n values :
100 ////////// MIS MULTPLIED BY 100.

Enter length of exponential seq :


20

Enter a value :
16
Output-

Conclusion -
With the help of MATLAB code and outputs we
have generated and analyzed different types of
analog signals and discreate sequences.

You might also like