0% found this document useful (0 votes)
2 views

DOC-20220606-WA0006.

The Signals & Systems Lab manual outlines a series of experiments aimed at providing practical experience with signal generation and analysis using MATLAB. Key objectives include understanding MATLAB basics, simulating signal operations, and analyzing signals using various transforms. The lab covers essential concepts such as convolution, correlation, and noise generation, along with detailed instructions on using MATLAB's features and functions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

DOC-20220606-WA0006.

The Signals & Systems Lab manual outlines a series of experiments aimed at providing practical experience with signal generation and analysis using MATLAB. Key objectives include understanding MATLAB basics, simulating signal operations, and analyzing signals using various transforms. The lab covers essential concepts such as convolution, correlation, and noise generation, along with detailed instructions on using MATLAB's features and functions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

SIGNALS & SYSTEMS LAB (C-13)

LAB MANUAL
SIGNALS & SYSTEMS LAB (C-13)
SIXTH SEMESTER
DEPT. OF INFORMATION SC. & TELECOMMUNICATION

(I.S.T.)
RAVENSHAW UNIVERSITY, CUTTACK

LIST OF THE EXPERIMENTs:

1. Generation of Signals: continuous time


2. Generation of Signals: discrete time
3. Time shifting and time scaling of signals.
4. Folding a given sequence
5. Addition of two discrete time signal
6. Linear Convolution of Signals
7. Circular Convolution of Signals
8. Auto correlation of a sequence.
9. Cross correlation of a sequence.
10. Fourier transform of continuous time signals.

Lab. In-charge:
Mr. Shakti Prasad Dash

1
SIGNALS & SYSTEMS LAB (C-13)

MATLAB:
The course aims at practical experience with the generation and simulation of basic
signals, using standardized environments such as MATLAB.

Experiments cover fundamental concepts of basic operation on matrices,


generation of various signals and sequences, operation on signals and sequences,
convolution, autocorrelation and cross correlation between signals and sequences.

The objective of this laboratory is to enable the students to acknowledge with basic
signals, and system responses.

OBJECTIVE

1. Understand the basics of MATLAB


2. Simulate the generation of signals and operations on them.
3. Analyze the signals using Fourier, Laplace and Z transforms.

COURSE OUTCOMES

1. Understand the applications of MATLAB and to generate matrices of various

dimension
2. Generate the various signals and sequences and perform operations on signals.

3. Obtain the frequency domain representation of signals and sequences using

Fourier transform, Laplace and z transform.


4. Understand the concept of convolution and correlation

5. Generation of various types of noise and measuring various characteristics of

noise.

2
SIGNALS & SYSTEMS LAB (C-13)

INTRODUCTION TO MATLAB
The name MATLAB stands for Matrix Laboratory. MATLAB was written originally to provide
easy access to matrix software developed by the LINPACK (linear system package) and
EISPACK (Eigen system package) projects.

MATLAB is a high-performance language for technical computing. It integrates computation,


visualization, and programming environment.

The software package has been commercially available since 1984.

MATLAB is a software package for high-performance language for technical computing. It


integrates computation, visualization, and Programing in an easy-to-use environment where
problems and solutions are expressed in familiar mathematical notation. Typical uses include the
following:

Math and computation


Algorithm development
Data acquisition
Modeling, simulation, and prototyping (prior to complex model development).
Data analysis, exploration, and visualization
Scientific and engineering graphics
Application development, including graphical user interface building.

Complex analysis using MATLAB toolboxes(i.e.,statistics, neural networks, fuzzy logic,


etc.)

THEORY:

MATLAB is a programming language developed by Math Works. It started out as a matrix


programming language where linear algebra programming was simple. MATLAB (matrix
laboratory) is a fourth-generation high-level programming language and interactive environment
for numerical computation, visualization and programming.
MATLAB is developed by Math Works. It allows matrix manipulations; plotting of functions
and data; implementation of algorithms; creation of user interfaces; interfacing with programs
written in other languages, including C, C++, Java, and FORTRAN; analyze data; develop
algorithms; and create models and applications.

3
SIGNALS & SYSTEMS LAB (C-13)

MATLAB ENVIRONMENT:

Command Window:
Whenever MATLAB is invoked, the main window called command window is activated. The
command window displays the command prompt’>>’ and a cursor where commands are entered and
are executed instantaneously.

Command History Window:


Command history window consists of a list of all the commands that are entered at the command
window. These commands remain in the list until they are deleted. Any command may be executed
by selecting and double clicking it with the mouse.

Workspace:
A workspace is a collection of all the variables that have been generated so far in the current
MATLAB session and shows their data type and size. All the commands executed from Command
Window and all the script files executed from the Command Window share common workspace, so
they can share all the variables.

Current Directory:
The Current Directory window contains all the files and folders present in the Current Directory. To
run any file, it must either be in the Current Directory or on the search path.

Edit Window:
An Edit Window is used to create a new program file, or to modify existing files. In this window,
programs can be written, edited and saved. The programs written using the MATLAB editor are
automatically assigned an extension (.m) by the editor and are known as M- files.

Figure Window:
A Figure Window is a separate window with default white background and is used to display
MATLAB graphics. The results of all the graphic commands executed are displayed in the figure
window

MATLAB works through three basic windows.

1. Command Window 2. Graphics window 3. Edit window

4
SIGNALS & SYSTEMS LAB (C-13)

Variables can be defined in MATLAB in the following ways:

x=3 % defining x and initializing it with a value


x = sqrt(16) % defining x and initializing it with an expression

The clear command deletes all (or the specified) variable(s) from the memory.

clear x % it will delete x, won't display anything


clear % it will delete all variables in the workspace

A vector is a one-dimensional array of numbers. MATLAB allows creating two types of


vectors:
Row vectors

Row vectors are created by enclosing the set of elements in square brackets, using space or
comma to delimit the elements.
For example:- r = [7 8 9 10 11]
Column vectors are created by enclosing the set of elements in square brackets, using
semicolon(;) to delimit the elements. c = [7; 8; 9; 10; 11]

Creating Matrices
A matrix is a two-dimensional array of numbers.

In MATLAB, a matrix is created by entering each row as a sequence of space or comma


separated elements, and end of a row is demarcated by a semicolon.

For example a 3-by-3 matrix is created as: m = [1 2 3; 4 5 6; 7 8 9]

Instructions/Functions:
stem (t,x) :- This instruction will display a figure window as shown.
stem(): Used for discrete time plotting of signals.

5
SIGNALS & SYSTEMS LAB (C-13)

11. Subplot: This function divides the figure window into rows and columns.
Subplot (2 2 1) divides the figure window into 2 rows and 2 columns 1 represent
number of the Subplot (3 1 2) divides the figure window into 3 rows and 1 column
2 represent the figure number.

12. Conv Syntax:


w = conv(u,v)
Description: w = conv(u,v) convolves vectors u and v. Algebraically, convolution
is the same operation as multiplying the polynomials whose coefficients are the
elements of u and v.

13. Disp Syntax: disp(X)

Description: disp(X) displays an array, without printing the array name. If X


contains a text string, the string is displayed.
Another way to display an array on the screen is to type its name, but this
prints a leading "X=," which is not always desirable.
Note: disp does not display empty arrays.

14. xlabel Syntax: xlabel('string')

Description: xlabel('string') labels the x-axis of the current axes.

15. ylabel Syntax : ylabel('string')

Description: ylabel('string') labels the y-axis of the current axes.

16. Title Syntax : title('string')

Description: title('string') OUTPUTs the string at the top and in the center of the
current axes.

17. min() and max() : used to find minimum and maximum value.

Syntax:

 min()

1. min(x) - returns smallest element in an array if x is an array.

6
SIGNALS & SYSTEMS LAB (C-13)

- returns a row vector containing minimum element from each column if x


is a matrix.
2. min(x,y) - returns an array with the same size of x and y. Elements of
corresponding indices are checked and minimum value is returned. x and y must
be of same length.

 max()

1. max(x) - returns largest element in an array if x is an array.


-returns a row vector containing maximum element from each column if x is a
matrix
2. max(x,y) - returns an array with the same size of x and y. Elements of
corresponding indices are checked and maximum value is returned. x and y must
be of same length.

19. The inbuilt function fliplr() function can be used to perform reversing or folding a signal.

Syntax:

 fliplr(a) : if a is row vector it returns a vector with the same size of a but with reversed
order. if a is column vector it flips the elements one column to the other.

Basic idea :

 flip the elements


 flip the indices with a ‘ – ‘ sign.

Starting MATLAB

One can enter MATLAB by double-clicking on the MATLAB shortcut icon on Windows
desktop.
Upon starting of MATLAB, a special window called the MATLAB desktop appears. The
desktop is a window that contains other windows. The major tools within or accessible from the
desktop are:

7
SIGNALS & SYSTEMS LAB (C-13)

•The Command Window: the


window in which the inputs and
out puts can be observed.
•The Command History: the
window consisting of the
instruction given in the command
during the previous sessions.
•The Workspace: the window
consisting of the variables used in
the programming.
• The Current Directory: the
directory consisting of m-files and
other files of use/work.

The major tools within or accessible from the desktop are:


•The Command Window •The Command History •The Workspace
• The Current Directory • The Help Browser • The Start button

Quitting MATLAB: To end your MATLAB session, type quit in the Command Window, or
select File Exit MATLAB in the desktop main menu.

Programming in MATLAB:
So far in these lab sessions, all the commands were executed in the Command Window. The
problem is that the commands entered in the Command Window cannot be saved and executed
again for several times. Therefore, a different way of executing repeatedly commands with
MATLAB is:
1. to create a file with a list of commands,
2. save the file, and
3. run the file. If needed, corrections or changes can be made to the commands in the file. The
files that are used for this purpose are called script files or scripts for short. This section covers
the following topics:

8
SIGNALS & SYSTEMS LAB (C-13)

-File Scripts: A script file is an external file that contains a sequence of MATLAB
statements.
Script files have a filename extension .m and are often called M-files. M-files can be scripts that
simply execute a series of MATLAB statements, or they can be functions that can accept
arguments and can produce one or more outputs.

The M Files
MATLAB allows writing two kinds of program files –

Scripts − script files are program files with .m extension. In these files, you write series of
commands, which you want to execute together. Scripts do not accept inputs and do not return
any outputs. They operate on data in the workspace.

Functions − functions files are also program files with .m extension. Functions can accept
inputs and return outputs. Internal variables are local to the function.

You can use the MATLAB editor or any other text editor to create your .m files.

Built in Functions:
1. Scalar Functions: Certain MATLAB functions are essentially used on scalars, but operate
element-wise when applied to a matrix (or vector).
They are summarized below.
1. sin - trigonometric sine
2. cos - trigonometric cosine
3. tan - trigonometric tangent
4. asin - trigonometric inverse sine (arcsine)
5. sqrt - square root 6. rem - remainder
2. Vector Functions: Other MATLAB functions operate essentially on vectors returning a
scalar value. Some of these functions are given below.

1. max- largest component: get the row in which the maximum element lies
2. min- smallest component
3. length- length of a vector
4. sort- sort in ascending order
5. sum- sum of elements

9
SIGNALS & SYSTEMS LAB (C-13)

3. Matrix Functions: Much of MATLAB‟s power comes from its matrix functions. These
can be further separated into two sub-categories. The first one consists of convenient matrix
building functions, some of which are given below.
1. eye - identity matrix
2. zeros - matrix of zeros
3. ones - matrix of ones
4. diag - extract diagonal of a matrix or create diagonal matrices

Apparatus Required:

 OS- Windows 7
 Matlab R2010A

MATLAB Procedure
Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window\ Figure window

MATLAB PROGRAMS
AIM of the Experiment 1 & 2 :
(1) Generation of Signals: continuous time
(2) Generation of Signals: discrete time
(a)%unit step function%
clc;
clear all;
close all;
N=100; t=1:100;
x=ones(1,N);

10
SIGNALS & SYSTEMS LAB (C-13)

subplot(2,1,1); plot(t,x,'g');
xlabel('time'); ylabel('amplitude'); title('unit step function');
subplot(2,1,2); stem(t,x,'r');
xlabel('time'); ylabel('amplitude'); title('unit step discrete function');

unit step function


2

1.5
amplitude

0.5

0
0 5 10 15 20 25 30
time
unit step discrete function
1
amplitude

0.5

0
0 5 10 15 20 25 30
time

(b)%unit impulse function%


clc;
clear all;
close all;
t=-10:1:10;
x=(t==0);
subplot(2,1,1); plot(t,x,'g');
xlabel('time'); ylabel('amplitude'); title('unit impulse function');
subplot(2,1,2); stem(t,x,'r');
xlabel('time'); ylabel('amplitude'); title('unit impulse discrete function');

11
SIGNALS & SYSTEMS LAB (C-13)

unit impulse function


1

amplitude
0.5

0
-10 -8 -6 -4 -2 0 2 4 6 8 10
time
unit impulse discrete function
1
amplitude

0.5

0
-10 -8 -6 -4 -2 0 2 4 6 8 10
time

(c)%unit ramp function%


clc;
clear all;
close all;
t=0:20;
x=t;
subplot(2,1,1); plot(t,x,'g');
xlabel('time'); ylabel('amplitude'); title('unit ramp function');
subplot(2,1,2); stem(t,x,'r');
xlabel('time'); ylabel('amplitude'); title('unit ramp discrete function');

12
SIGNALS & SYSTEMS LAB (C-13)

unit ramp function


20

15

amplitude
10

0
0 2 4 6 8 10 12 14 16 18 20
time
unit ramp discrete function
20

15
amplitude

10

0
0 2 4 6 8 10 12 14 16 18 20
time

(d)%sinusoidal function%
clc;
clear all;
close all;
t=0:0.05:1.4;
x=sin(2*pi*t);
subplot(2,1,1); plot(t,x,'g');
xlabel('time'); ylabel('amplitude'); title('sinusoidal signal');
subplot(2,1,2); stem(t,x,'r');
xlabel('time'); ylabel('amplitude'); title('sinusoidal sequence');

13
SIGNALS & SYSTEMS LAB (C-13)

(e)%sinc function%
clc;
clear all;
close all;
t=linspace(-5,5);
x=sinc(t);
subplot(2,1,1); plot(t,x,'g');
xlabel('time'); ylabel('amplitude'); title('sinc signal');
subplot(2,1,2); stem(t,x,'r');
xlabel('time'); ylabel('amplitude'); title('sinc sequence');

14
SIGNALS & SYSTEMS LAB (C-13)

sinc signal
1

0.5
amplitude

-0.5
-5 -4 -3 -2 -1 0 1 2 3 4 5
time
sinc sequence
1

0.5
amplitude

-0.5
-5 -4 -3 -2 -1 0 1 2 3 4 5
time

(a) Generating two input signals (continuous)

clc;
clear all;
close all;
t=0:0.01:1;
(f-1) % generating two input signals
x1=sin(2*pi*4*t);
x2=sin(2*pi*8*t);
subplot(2,2,1); plot(t,x1);
xlabel('time'); ylabel('amplitude'); title('signal1:sine wave of frequency 4Hz');
subplot(2,2,2); plot(t,x2);
xlabel('time'); ylabel('amplitude'); title('signal2:sine wave of frequency 8Hz');
(f-2) % addition of signals
y1=x1+x2;
subplot(2,2,3); plot(t,y1);
xlabel('time'); ylabel('amplitude'); title('resultant signal:signal1+signal2');

15
SIGNALS & SYSTEMS LAB (C-13)

(f-3) % multiplication of signals


y2=x1.*x2;
subplot(2,2,4); plot(t,y2);
xlabel('time'); ylabel('amplitude'); title('resultant signal: dot product of signal1 and signal2');

signal1:sine wave of frequency 4Hz signal2:sine wave of frequency 8Hz


1 1

0.5 0.5
amplitude

amplitude
0 0

-0.5 -0.5

-1 -1
0 0.5 1 0 0.5 1
time time
resultant signal:signal1+signal2 resultant signal:dot product of signal1 and signal2
2 1

1 0.5
amplitude

amplitude

0 0

-1 -0.5

-2 -1
0 0.5 1 0 0.5 1
time time

(g)% generating two input signals


clc;
clear all;
close all;
t=0:0.01:1;
x1=sin(2*pi*4*t);x2=sin(2*pi*8*t);
subplot(2,2,1);plot(t,x1);
xlabel('time');ylabel('amplitude');
title('signal1:sine wave of frequency 4Hz');
subplot(2,2,2);plot(t,x2);
xlabel('time');ylabel('amplitude');
title('signal2:sine wave of frequency 8Hz');

16
SIGNALS & SYSTEMS LAB (C-13)

Conclusion : From the above, Various operations on signals and sequences are performed.

AIM of the Experiment 3 : Time shifting and time scaling of signals.

(a)Shifting of a signal.
%shifting of a signal
figure; t1=0:.01:pi;
x3=8*sin(2*pi*2*t1);
subplot(3,1,1); plot(t1,x3);
xlabel('time t1'); ylabel('amplitude'); title('sine wave of frequency 2Hz');
subplot(3,1,2); plot(t1+10,x3);
xlabel('t1+10'); ylabel('amplitude'); title('right shifted signal');
subplot(3,1,3); plot(t1-10,x3);
xlabel('t1-10'); ylabel('amplitude'); title('left shifted signal');

17
SIGNALS & SYSTEMS LAB (C-13)

sine wave of frequency 2Hz


10
amplitude

-10
0 0.5 1 1.5 2 2.5 3 3.5
time t1
right shifted signal
10
amplitude

-10
10 10.5 11 11.5 12 12.5 13 13.5
t1+10
left shifted signal
10
amplitude

-10
-10 -9.5 -9 -8.5 -8 -7.5 -7 -6.5
t1-10

Conclusion :- All the operations have been performed using a MATLAB and results have been
seen on the command window.

(b)% scaling of signal1 & signal2


clc;
clear all;
close all;
t=0:0.01:1;
x1=sin(2*pi*4*t);x2=sin(2*pi*8*t);
A=10; y3=A*x1; figure;
A=20; y4=A*x2; figure;
subplot(2,2,1); plot(t,x1);
xlabel('time'); ylabel('amplitude');
title('sine wave of frequency 4Hz');
subplot(2,2,2);plot(t,y3);
xlabel('time'); ylabel('amplitude');
title('amplified input signal1 ');

18
SIGNALS & SYSTEMS LAB (C-13)

subplot(2,2,3); plot(t,x2);
xlabel('time'); ylabel('amplitude');
title('sine wave of frequency 8Hz');
subplot(2,2,4);plot(t,y4);
xlabel('time'); ylabel('amplitude');
title('amplified input signal2 ');

sine wave of frequency 4Hz amplified input signal1


1 10

0.5 5
amplitude

amplitude
0 0

-0.5 -5

-1 -10
0 0.5 1 0 0.5 1
time time
sine wave of frequency 8Hz amplified input signal2
1 20

0.5 10
amplitude

amplitude

0 0

-0.5 -10

-1 -20
0 0.5 1 0 0.5 1
time time

Conclusion : From the above, Various operations on signals and sequences are performed.

(c)% scaling of a signal1


clc;
clear all;
close all;
t=0:0.01:1;
x1=sin(2*pi*4*t);x2=sin(2*pi*8*t);
A=10; y3=A*x1; figure;
subplot(2,2,1); plot(t,x1);
xlabel('time');ylabel('amplitude');title('sine wave of frequency
4Hz');
subplot(2,2,2);plot(t,y3);

19
SIGNALS & SYSTEMS LAB (C-13)

xlabel('time');ylabel('amplitude');title('amplified input signal1');

Conclusion : From the above, Various operations on signals and sequences are performed.

AIM of the Experiment 4: Folding a given sequence.

(a)% folding of a signal1


l1=length(x1); nx=0:l1-1;
subplot(2,2,1); plot(nx,x1);
xlabel('nx'); ylabel('amplitude'); title('sine wave of frequency 4Hz');
y4=fliplr(x1);
nf=-fliplr(nx);
subplot(2,2,2); plot(nf,y4);
xlabel('nf'); ylabel('amplitude'); title('folded signal');

[Amplitude scaling of a signal]

20
SIGNALS & SYSTEMS LAB (C-13)

(b)% Folding a discrete time signals


clc;
clear all;
close all;
n=0:8;
x=[0 0 1 2 3 4 5 4 3];
subplot(2,1,1);stem(n,x);title('x(n)signal');
xlabel('n');ylabel('x(n)');
m=-fliplr(n);y=fliplr(x);
subplot(2,1,2);stem(m,y);title('y(n)=x(-n)signal');
xlabel('n');ylabel('y(n)');

x(n)signal
6

4
x(n)

0
0 1 2 3 4 5 6 7 8
n
y(n)=x(-n)signal
6

4
y(n)

0
-8 -7 -6 -5 -4 -3 -2 -1 0
n

Conclusion : From the above, Various operations on signals and sequences are performed.

AIM of the experiment 5: Addition of two Discrete time Signals.

% discrete time addition y(n)= x1(n)+ x2(n)


clc;
clear all;
close all;
n1= 0:4;

21
SIGNALS & SYSTEMS LAB (C-13)

x1=[0 1 2 3 4];
subplot(3,1,1);stem(n1,x1);title('x_1(n)signal');
xlabel('n');ylabel('x_1(n)');
n2= -2:2;
x2=[2 2 2 2 2];
subplot(3,1,2);stem(n2,x2);title('x_2(n)signal');
xlabel('n');ylabel('x_2(n)');
n = min(min(n1),min(n2)):max(max(n1),max(n2)); %duration of y(n)
y1 = zeros(1,length(n));y2=y1; %initialization
y1((n>= min(n1))& (n<= max(n1))== 1)= x1; % x1 with duration of y
y2((n>= min(n2))& (n<= max(n2))== 1)= x2; % x2 with duration of y
y=y1+y2; % sequence addition
subplot(3,1,3);stem(n,y);
title('Addition of the discrete time signals');
xlabel('n');ylabel('y(n)');

OUTPUT:

Conclusion: From the above, Various operations on signals and sequences are performed.

AIM of the Experiment 6: Linear Convolution involves the following operations.


1. Folding
2. Multiplication

22
SIGNALS & SYSTEMS LAB (C-13)

3. Addition

4. Shifting

These operations can be represented by a Mathematical Expression as follows:

PROGRAM:
clc;
close all;
clear all;
x=input('enter input sequence');
h=input('enter impulse response');
y=conv(x,h);
subplot(3,1,1); stem(x);
xlabel('n');ylabel('x(n)'); title('input signal');
subplot(3,1,2); stem(h);
xlabel('n');ylabel('h(n)'); title('impulse response');
subplot(3,1,3); stem(y);
xlabel('n');ylabel('y(n)'); title('linear convolution');
disp('The resultant signal is');
disp(y)

linear convolution
INTPUT:

23
SIGNALS & SYSTEMS LAB (C-13)

enter input sequence[1 4 3 2]

enter impulse response[1 0 2 1]

OUTPUT: The resultant signal is

1 4 5 11 10 7 2

Conclusion: From the above, Various operations on signals and sequences are performed.

AIM of the Experiment 7: Linear and Circular Convolution.


For two vectors, x and y, the circular convolution is equal to the inverse discrete Fourier
transform (IDFT) of the product of the vectors' DFTs.

Knowing the conditions under which linear and circular convolution are equivalent allows you to use the
DFT to efficiently compute linear convolutions.

The linear convolution of an N-point vector, x and an L-point vector, y has length N + L - 1.

PROGRAM:

clc;
clear all;
close all;

24
SIGNALS & SYSTEMS LAB (C-13)

%Create two vectors, x and y, and compute the linear convolution of the two
vectors%

x = [2 1 2 1];y = [1 2 3];
clin = conv(x,y);

%The output has length 4+3-1%

%Pad both vectors with zeros to length 4+3-1. Obtain the DFT of both vectors,
multiply the DFTs, and obtain the inverse DFT of the product%
xpad = [x zeros(1,6-length(x))];
ypad = [y zeros(1,6-length(y))];
ccirc = ifft(fft(xpad).*fft(ypad));

The circular convolution of the zero-padded vectors, xpad and ypad, is equivalent to the
linear convolution of x and y.

%Plot the output of linear convolution and the inverse of the DFT product to show the
equivalence%
subplot(2,2,1)
stem(clin,'filled')
ylim([0 11])
title('Linear Convolution of x and y')
subplot(2,2,2)
stem(ccirc,'filled')
ylim([0 11])
title('Circular Convolution of xpad and ypad')

Conclusion: From the above, Various operations on signals and sequences are performed.

25
SIGNALS & SYSTEMS LAB (C-13)

AIM of the Experiment 8 & 9 : To compute auto-correlation and cross-correlation


between signals and sequences.

Correlations of sequences: It is a measure of the degree to which two sequences are similar.
Given two real valued Sequences x(n) and y(n) of finite energy,

Convolution involves the following operations.


1. Shifting

2. Multiplication

3. Addition
These operations can be represented by a Mathematical Expression as follows:

Cross correlation

The index l is called the shift or lag parameter.

Autocorrelation

PROGRAM:

% Cross Correlation
clc;
close all;

clear all;

x=input('enter input sequence');

h=input('enter the impulse suquence');

subplot(3,1,1); stem(x);

26
SIGNALS & SYSTEMS LAB (C-13)

xlabel('n'); ylabel('x(n)'); title('input signal');

subplot(3,1,2); stem(h);

xlabel('n'); ylabel('h(n)'); title('impulse signal');

y=xcorr(x,h);

subplot(3,1,3); stem(y);

xlabel('n'); ylabel('y(n)');

disp('the resultant signal is');

disp(y); title('correlation signal');

INPUT: On command window

enter input sequence[2 3 4]

enter the impulse suquence[2 2 2]

the resultant signal is

4.0000 10.0000 18.0000 14.0000 8.0000

OUTPUT:

27
SIGNALS & SYSTEMS LAB (C-13)

(b) % auto correlation


clc;
close all;
clear all;
x = [1,2,3,4,5]; y = [4,1,5,2,6];
subplot(3,1,1); stem(x);
xlabel('n'); ylabel('x(n)'); title('input signal');
subplot(3,1,2); stem(y);
xlabel('n'); ylabel('y(n)'); title('input signal');
z=xcorr(x,x);
subplot(3,1,3); stem(z);
xlabel('n'); ylabel('z(n)'); title('resultant signal');

OUTPUT:

AIM of the Experiment 10 : To find the Fourier Transform of a given signal and
plotting its magnitude and phase spectrum.

PROGRAM:
clc;
close all;

28
SIGNALS & SYSTEMS LAB (C-13)

clear all;
x=input ('enter the sequence');
N=length(x);
n=0:1:N-1;
y=fft(x,N);
subplot(2,1,1); stem(n,x);title('input sequence');
xlabel('time index n----->');
ylabel('amplitude x[n]----> ');
subplot(2,1,2);stem(n,y);title('OUTPUT sequence');
xlabel(' Frequency index K---->');

ylabel('amplitude X[k]------>');

INPUT: Enter the sequence [2 4 6]

OUTPUT: 12 -3 -3

Conclusion: From the above, Various operations on signals and sequences are performed.

29

You might also like