Download as pdf or txt
Download as pdf or txt
You are on page 1of 71

TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

(AUTONOMOUS)
MEDBOWLI, MEERPET, RANGA REDDY

DEPARTMENT OF ECE

NAME:

ROLL NO:

BASIC SIMULATION LAB


OBSERVATION
FOR

II B.Tech ECE-A
2021-22
LIST OF EXPERIMENTS

1. Basic Operations on Matrices.


2. Generation of Various Signals and Sequences (Periodic and Aperiodic), such as Unit Impulse, Unit Step,
Square, Saw tooth, Triangular, Sinusoidal, Ramp, Sinc.
3. Operations on Signals and Sequences such as Addition, Multiplication, Scaling, Shifting, Folding,
Computation of Energy and Average Power.
4. Finding the Even and Odd parts of Signal/Sequence and Real and Imaginary parts of Signal.
5. Convolution for Signals and sequences.
6. Auto Correlation and Cross Correlation for Signals and Sequences.
7. Verification of Linearity and Time Invariance Properties of a given Continuous/Discrete System.
8. Computation of Unit sample, Unit step and Sinusoidal responses of the given LTI system and verifying its
physical reliability and stability properties.
9. Gibbs Phenomenon Simulation.
10.Finding the Fourier Transform of a given signal and plotting its magnitude and phase spectrum.
11.Waveform Synthesis using Laplace Transform.
12. Locating the Zeros and Poles and plotting the Pole-Zero maps in S-plane and Z-Plane for the given transfer
function.
13. Generation of Gaussian noise (Real and Complex), Computation of its mean, M.S. Value and its Skew,
Kurtosis, and PSD, Probability Distribution Function.
14. Sampling Theorem Verification.
15. Removal of noise by Autocorrelation / Cross correlation.
16.Extraction of Periodic Signal masked by noise using Correlation.
17.Verification of Weiner-Khintchine Relations.
18. Checking a Random Process for Stationary in Wide sense.

Signature of the staff member

2|BSLAB DepartmentofECE
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. Furthermore, MATLAB is a modern programming language
environment, it has sophisticated data structures, contains
built-in editing and debugging tools, and supports object-oriented programming. These factors make
MATLAB an excellent tool for teaching and research.
MATLAB has many advantages compared to conventional computer languages (e.g., C,
FORTRAN) for solving technical problems. MATLAB is an interactive system whose basic data element
is an array that does not require dimensioning. The software package has been commercially available
since 1984 and is now considered as a standard tool at most universities and industries worldwide.
It has powerful built-in routines that enable a very wide variety of computations. It also has easy to
use graphics commands that make the visualization of results immediately available. Specific applications
are collected in packages referred to as toolbox. There are toolboxes for signal processing, symbolic
computation, control theory, simulation, optimization, and several other fields of applied science and
engineering.
Matlab Window:
After logging into your account, you can enter MATLAB by double-clicking on the MATLAB
shortcut icon (MATLAB 2013a) on your Windows desktop. When you start 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...
The Command Window
The Command History
The Workspace
The Current Directory
The Help Browser
The Start button

3|BSLAB DepartmentofECE
Specialities of MATLAB:

MATLAB is case-sensitive, which means that a + B is not the same as a + b.


The MATLAB prompt (») in command window is where the commands are entered.

Matrices Representation:

1. row matrix:
Elements in a row are separated either by using white spaces or commas e.g.: a=[1 2 4 5]
2. column matrix:
Elements which differ by a column are separated by enter or semi column e.g.: b=[1; 2; 3]

Looking into particular element:


• a(row, column) allows to look the particular element in the matrix “a”
ex: a=[1 2 4,5 4 6,8 5 7]
b=a(5);
Here b value will be 4.
Vectors:
• d= [0:7]
”d” is a vector or row matrix with first element as 0 and last element as 7 and increment is by

4|BSLAB DepartmentofECE
default 1.
Ans: d= [0 1 2 3 4 5 6 7]
• The default increment can be changed (to 0.1) by using increment field in between as
e= [0:0.1:1]
Ans: e=[0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0]
• g(1:2:9) look with increment 2
Ans: g=[1 3 5 7 9]
Operators:
1. + addition
2. - subtraction
3. * multiplication
4. ^ power
5. ' transpose
6. \ left division
7. / right division
• Remember that the multiplication, power and division operators can be used in conjunction with a
period to specify an element-wise operation.
Typical commands:
1. clc - to clear the command window.
2. close all - to close the previous program figures.
3. clear all - to clear the work space.
4. quit or exit - to close the MATLAB
5. save filename - filename.mat
6. load filename - retrive
7. dairy filename - b4 and after ascii text file
8. help - to search required query.
Built in Functions:
1. Scalar Functions:
• Certain MATLAB functions are essentially used on scalars, but to 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. acos - trigonometric inverse cosine (arccosine)
6. atan - trigonometric inverse tangent (arctangent)
7. exp - exponential

5|BSLAB DepartmentofECE
8. log - natural logarithm
9. abs - absolute value
10. sqrt - square root
11. rem - remainder
12. round - round towards nearest integer
13. floor - round towards negative infinity
14. ceil - round towards positive infinity
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
2. min -smallest component
3. length -length of a vector
4. sort -sort in ascending order
5. sum -sum of elements
6. prod -product of elements
7. median -median value
8. mean -mean value std standard deviation
Few more commands:
Commands in the second sub-category of matrix functions are
1. size -size of a matrix
2. det -determinant of a square matrix
3. inv -inverse of a matrix
4. rank -rank of a matrix
5. rref -reduced row echelon form
6. eig -eigen values and eigenvectors
7. poly -characteristic polynomial
8. norm -norm of matrix (1-norm, 2-norm, ∞ -norm)
9. cond -condition number in the 2-norm
10. lu -LU factorization
11. qr -QR factorization
12. chol -Cholesky decomposition
13. svd -singular value decomposition

6|BSLAB DepartmentofECE
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
5. triu - upper triangular part of a matrix
6. tril - lower triangular part of a matrix
7. rand - randomly generated matrix

7|BSLAB DepartmentofECE
TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

Experiment No-1

BASIC OPERATIONS ON MATRICES

AIM: - To write a MATLAB program to perform some basic operation on matrices


such as addition, subtraction, multiplication, division, array division and array
multiplication.

SOFTWARE REQURIED:-

MATLAB R2013a (8.1 Version).

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

PROGRAM:-

clc;
close all;
clear all;
a=[1 2 -9;2 -1 2;3 -4 3];
b=[1 2 3;4 5 6;7 8 9];
disp('The matrix a= ');a
disp('The matrix b= ');b
% to find sum of a and b
c=a+b;
disp('The sum of a and b is ');c
% to find difference of a and b
d=a-b;
disp('The difference of a and b is ');d
%to find multiplication of a and b
e=a*b;
disp('The product of a and b is ');e
% to find element-by-element multiplication
f=a.*b;
disp('element to element multiplication of a and b is');f
%to find division of a and b
g=a/b;
disp('The of division a and b is');g
%to find element to element division of a and b
h=a./b;
disp('element to element division of a and b is');h

BS LAB DEPT OF ECE


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

RESULT:-
Finding of addition, subtraction, multiplication using Matlab was
Successfully completed

OUTPUT:-

The matrix a=
a=
1 2 -9
2 -1 2
3 -4 3

The matrix b=
b=
1 2 3
4 5 6
7 8 9

The sum of a and b is


c=
2 4 -6
6 4 8
10 4 12

The difference of a and b is


d=
0 0 -12
-2 -6 -4
-4 -12 -6

The product of a and b is


e=
-54 -60 -66
12 15 18
8 10 12

element to element multiplication of a and b is


f=
1 4 -27
8 -5 12
21 -32 27

BS LAB DEPT OF ECE


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

The of division a and b is


g=
1.0e+017 *

0.5404 -1.0809 0.5404


-0.2702 0.5404 -0.2702
-0.6305 1.2610 -0.6305

element to element division of a and b is


h=
1.0000 1.0000 -3.0000
0.5000 -0.2000 0.3333
0.4286 -0.5000 0.3333

BS LAB DEPT OF ECE


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

Experiment No-02

GENERATION OF VARIOUS SIGNALS & SEQUENCES

AIM: -
Generate the various signals such as unit impulse, unit step, sine, sawtooth, square,
triangle, sinc function both in continuous and in discrete manner by using MATLAB.

SOFTWARE REQUIRED:-

• MATLAB R2013a (8.1 Version).


.
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
PROGRAMME:-

clc;
clear all;
close all;
%unit impulse generation for discrete signal
t1=-2:1:2;
y1=[zeros(1,2),ones(1,1),zeros(1,2)];
stem(t1,y1,'r','linewidth',2);
xlabel('n');
ylabel('amplitude');
title('unit impulse for discrete signal');
figure;
%unit impulse generation for continious signal
T=15;%input('enter the time interval=');
t2=-T:0.01:T;
a1=length(t2);
y2=[zeros(1,(a1-1)/2),ones(1,1),zeros(1,(a1-1)/2)];
plot(t2,y2,'r','linewidth',2);
xlabel('time');
ylabel('amplitude');
title('unit impulse for continious signal');
figure;
%unit step generation for discrete and continious signal
n=15;%input('enter the value of n=');
t3=0:1:n-1;

BS LAB DEPT OF ECE


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

y3=ones(1,n);
subplot(2,1,1);
stem(t3,y3,'m','linewidth',2);
xlabel('t(n)');
ylabel('amplitude');
title('unit step generation for discrete signal');
subplot(2,1,2);
plot(t3,y3,'r','linewidth',2);
xlabel('time');
ylabel('amplitude');
title('unit step generation for continious signal');
figure;
%Ramp signal generation for discrete and continious signal.
m=15;%input('enter the input sequences of ramp=');
t4=0:m;
subplot(2,1,1);
stem(t4,t4,'r','linewidth',2);
xlabel('t(n)');
ylabel('amplitude');
title('Ramp signal generation for discrete sequence');
subplot(2,1,2);
plot(t4,t4,'b','linewidth',2);
xlabel('time');
ylabel('amplitude');
title('Ramp signal generation for continious signal');
%Sine signal generation for continious and discrete signal.
a5=3; %amplitude in db
f=2; %frequency 10 hz
t5=0:1/f:50; %0 and 10 are the time limits
y5=a5*sin(2*pi*1/10*t5);
subplot(2,1,1);
plot(t5,y5,'g','linewidth',2);
xlabel('time');
ylabel('amplitude');
title('Continious sine wave generation');
grid on;
subplot(2,1,2);
stem(t5,y5,'m','linewidth',1);
xlabel('t(n)');
ylabel('amplitude');
title('Discrete sine signal generation');
grid on;
figure;
%square wave signal generation for continious and discrete manner.
a6=5; %amplitude of the signal
fs1=1000; %signal frequency
t6=0:1/fs1:2;
y6=a6*square(2*pi*8*t6);
subplot(2,1,1);
plot(t6,y6,'b','linewidth',2);

BS LAB DEPT OF ECE


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

xlabel('time');
ylabel('amplitude');
title('Square wave signal generation');
grid on;
subplot(2,1,2);
stem(t6,y6,'m','linewidth',0.5);
xlabel('t(n)');
ylabel('amplitude');
title('Discrete square signal generation');
grid on;
figure;
%sawtooth wave signal generation for continious and discrete manner.
a7=5; %amplitude of the signal
fs2=100; %signal frequency
t7=0:1/fs2:2;
y7=a7*sawtooth(2*pi*5*t7);
subplot(2,1,1);
plot(t7,y7,'b','linewidth',2);
xlabel('time');
ylabel('amplitude');
title('continious Sawtooth signal generation');
grid on;
subplot(2,1,2);
stem(t7,y7,'m','linewidth',0.5);
xlabel('t(n)');
ylabel('amplitude');
title('Discrete sawtooth signal generation');
grid on;
figure;
%triangular wave signal generation for continious and discrete manner.
a8=5; %amplitude of the signal
fs3=100; %signal frequency
t8=0:1/fs3:2;
y8=a8*sawtooth(2*pi*5*t8,0.50); %0.50 is angle
subplot(2,1,1);
plot(t8,y8,'b','linewidth',2);
xlabel('time');
ylabel('amplitude');
title('continious triangle signal generation');
grid on;
subplot(2,1,2);
stem(t8,y8,'m','linewidth',0.5);
xlabel('t(n)');
ylabel('amplitude');
title('Discrete triangle signal generation');
grid on;
figure;
%generation of sinc signal in continious and discrete domain.
a9=7; %signal amplitude
t9=linspace(-5,5);

BS LAB DEPT OF ECE


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

y9=sinc(t9);
subplot(2,1,1);
plot(t9,y9,'b','linewidth',2);
xlabel('time');
ylabel('amplitude');
title('continious sinc signal generation');
grid on;
subplot(2,1,2);
stem(t9,y9,'r','linewidth',1);
xlabel('t(n)');
ylabel('amplitude');
title('Discrete sinc signal generation');
grid on;
Results:
Generation of various signals and sequences in continuous and also in discrete domain
are observed.

Graphs:

Result for unit impulse discrete signal:

unit impulse for discrete signal


1

0.9

0.8

0.7

0.6
amplitude

0.5

0.4

0.3

0.2

0.1

0
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
n

BS LAB DEPT OF ECE


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

Result for unit simpulse continuous signal:

unit impulse for continious signal


1

0.9

0.8

0.7

0.6
amplitude

0.5

0.4

0.3

0.2

0.1

0
-15 -10 -5 0 5 10 15
time

Result for step discrete and continious signal:

unit step generation for discrete signal


1

0.8
amplitude

0.6

0.4
0.2
0
0 2 4 6 8 10 12 14
t(n)
unit step generation for continious signal
2

1.5
amplitude

0.5

0
0 2 4 6 8 10 12 14
time

BS LAB DEPT OF ECE


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

Result for continious and discrete sine wave:

Continious sine wave generation


4

2
amplitude

-2

-4
0 10 20 30 40 50
time
Discrete sine signal generation
4

2
amplitude

-2

-4
0 10 20 30 40 50
t(n)

Result for square wave continious and discrete :

Square wave signal generation


5
amplitude

-5
0 0.5 1 1.5 2
time
Discrete square signal generation
5
amplitude

-5
0 0.5 1 1.5 2
t(n)

BS LAB DEPT OF ECE


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

Result for sawtooth wave :

continious Sawtooth signal generation


5
amplitude

-5
0 0.5 1 1.5 2
time
Discrete sawtooth signal generation
5
amplitude

-5
0 0.5 1 1.5 2
t(n)

Result for triangle pulse:

continious triangle signal generation


5
amplitude

-5
0 0.5 1 1.5 2
time
Discrete triangle signal generation
5
amplitude

-5
0 0.5 1 1.5 2
t(n)

BS LAB DEPT OF ECE


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

Result for sinc function in continuous and in discrete manner:

continious sinc signal generation


1
amplitude

0.5

-0.5
-5 0 5
time
Discrete sinc signal generation
1
amplitude

0.5

-0.5
-5 0 5
t(n)

BS LAB DEPT OF ECE


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

Experiment No-03

OPERATIONS ON SIGNALS AND SEQUENCES

AIM: - To perform various operations on signals such as addition, multiplication,


Scaling, shifting and folding in continuous and discrete manner by using
MATLAB.

SOFTWARE REQURIED :-
MATLAB R2013a (8.1 Version).
. .
PROCEDURE:-

• Open MATLAB
• Open new M-file
• Type the program
• Save in current directory
• Compile and Run the program
THEORY: • For the output see command window\ Figure window
➢ Signal Addition

Addition: any two signals can be added to form a third signal,


z (t) = x (t) + y (t)

➢ Multiplication :
Multiplication of two signals can be obtained by multiplying their values
at every instants. z (t) = x (t).* y (t)

Time reversal/Folding:
Time reversal of a signal x(t) can be obtained by folding the signal about
t=0. Y(t)=y(-t).

BS LAB DEPT OF ECE


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

Signal Amplification/Scaling :
Y(n)=ax(n) if a < 1 attnuation a >1 amplification.

Time shifting:
The time shifting of x(n) obtained by delay or advance the signal in time
by using y(n)=x(n+k)
If k is a positive number, y(n) shifted to the right i e the shifting delays
the signal
If k is a negative number, y(n ) it gets shifted left. Signal Shifting
advances the signal

Programme:
clc;
close all;
clear all;
a=2; %amplitude
t=0:0.001:1;
L=length(t);
f1=1; %frequency for 1st sin signal
f2=3; %frequency for 2nd sin signal
%programme for addition of two signals
x1=a*sin(2*pi*f1*t);
subplot(3,1,1);
plot(t,x1,'b','linewidth',2);
xlabel('time');
ylabel('amplitude');
title('the signals x1(t) and x2(t)');
grid on;
x2=a*sin(2*pi*f2*t);
subplot(3,1,2);
plot(t,x2,'r','linewidth',2);
grid on;
x3=x1+x2;
subplot(3,1,3);
plot(t,x3,'g','linewidth',2);
grid on;
figure;
title('the sum of x1(t) and x2(t)');
grid on
%programme for multiplication of two signals
y1=a*sin(2*pi*f1*t);
subplot(3,1,1);
plot(t,y1,'b','linewidth',2);
xlabel('time');
ylabel('amplitude');
title('the signals y1(t) and y2(t)');
grid on;
y2=a*sin(2*pi*f2*t);

BS LAB DEPT OF ECE


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

subplot(3,1,2);
plot(t,y2,'r','linewidth',2);
grid on;
y3=y1.*y2;
subplot(3,1,3);
plot(t,y3,'m','linewidth',2);
grid on;
figure;
title('the multiplication of y1(t) and y2(t)');
grid on;
%programme for folding of signals
z1=a*sin(2*pi*f1*(-t));
subplot(2,1,1);
plot(t,z1,'b','linewidth',2);
xlabel('time');
ylabel('amplitude');
title('the folding of z1(t)and z2(t)');
grid on;
z2=a*sin(2*pi*f2*(-t));
subplot(2,1,2);
plot(t,z2,'r','linewidth',2);
grid on;
figure;
%shifting of signals
w=[zeros(1,200),x2(1:(L-200))];
plot(t,w,'r','linewidth',2);
xlabel('time');
ylabel('amplitude');
title('the shifting of w');
grid on;
figure;
%squaring of signals
w1=x1.^2;
subplot(2,1,1);
plot(t,w1,'r','linewidth',2);
xlabel('time');
ylabel('amplitude');
title('the squaring of x1(t)and x2(t)');
grid on;
w2=x2.^2;
subplot(2,1,2);
plot(t,w2,'g','linewidth',2);
xlabel('time');
ylabel('amplitude');
grid on;
%Basic operations for Discrete sequences
n1=1:1:9;
s1=[1 2 3 4 5 6 2 3 1]; %1st sequence s1
subplot(4,1,1);
stem(n1,s1,'r','linewidth',2);

BS LAB DEPT OF ECE


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

xlabel('t(n1)');
ylabel('amplitude');
title('input sequence');
n2=-2:1:6;
s2=[1 1 0 0 2 3 1 1 0]; %2nd sequence s2
subplot(4,1,2);
stem(n2,s2,'g','linewidth',2);
xlabel('n2');
ylabel('amplitude');
title('input sequence');
s3=s1+s2; % addition of s1 & s2 sequences
subplot(4,1,3);
stem(n2,s3,'m','linewidth',2);
xlabel('n2');
ylabel('amplitude');
title('input sequence');
subplot(4,1,4);
s4=s1.*s2; % multiplication of s1 & s2 sequences
stem(n2,s4,'y','linewidth',2);
xlabel('n2');
ylabel('amplitude');
title('input sequence');
figure;
%program for folding sequence
n3=0:1:10;
x=0.5.*n3;
lx=length(x);
nx=0:lx-1;
xf=fliplr(x);
nf=-fliplr(x);
subplot(2,1,1);
stem(nx,x,'r','linewidth',2);
xlabel('nx');
ylabel('x(nx)');
title('original sequence');
subplot(2,1,2);
stem(nf,xf,'g','linewidth',2);
xlabel('nx');
ylabel('x(nx)');
title('folded sequence');
figure;
%program for amplitude scaling sequence
n4=0:1:6;
s1=[5 15 10 5 5 10 5];
subplot(3,1,1);
stem(s1,'r','linewidth',2);
xlabel('n');
ylabel('amplitude');
title('input sequence');
s2=5.*s1;

BS LAB DEPT OF ECE


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

subplot(3,1,2);
stem(s2,'b','linewidth',2);
xlabel('n');
ylabel('amplitude');
title('amplified input sequence');
s3=s1./5;
subplot(3,1,3);
stem(s3,'m','linewidth',2);
xlabel('n');
ylabel('amplitude');
title('attenuated input sequence');
figure;
%program for time shifting sequence
n=0:1:4;
h=[1 1 1 -1 2];
subplot(3,1,1);
stem(n,h,'r','linewidth',2);
xlabel('n');
ylabel('h(n)');
title('input sequence');
subplot(3,1,2);
stem(n+2,h,'b','linewidth',2);
xlabel('n');
ylabel('h(n)');
title('right shifted sequence');
subplot(3,1,3);
stem(n-2,h,'m','linewidth',2);
xlabel('n');
ylabel('h(n)');
title('left shifted sequence');

Result:
Hence the various basic operations of basic signals in continuous and discrete manner
are observed.

BS LAB DEPT OF ECE


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

Addition of two signals:


the signals x1(t) and x2(t)
2
amplitude

-2
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
time

-2
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

-5
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

Multiplication of two signals:


the signals y1(t) and y2(t)
2
amplitude

-2
0 0.2 0.4 0.6 0.8 1
time

-2
0 0.2 0.4 0.6 0.8 1

-5
0 0.2 0.4 0.6 0.8 1

BS LAB DEPT OF ECE


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

Folding of Signals:
the folding of z1(t)and z2(t)
2

1
amplitude

-1

-2
0 0.2 0.4 0.6 0.8 1
time

-1

-2
0 0.2 0.4 0.6 0.8 1

Shifting of Signals:
the shifting of w
2

1.5

0.5
amplitude

-0.5

-1

-1.5

-2
0 0.2 0.4 0.6 0.8 1
time

BS LAB DEPT OF ECE


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

Discrete signals addition and multiplication:


input sequence
10
amplitude

0
1 2 3 4 input se5quence 6 7 8 9
4 t(n1)
amplitude

0
-2 -1 0 1 2 3 4 5 6
input sne2quence
amplitude

10
5
0
-2 -1 0 1 2 3 4 5 6
n2
input sequence
amplitude

20
10
0
-2 -1 0 1 2 3 4 5 6
n2

Discrete Folded sequence:


original sequence
5
4
3
x(nx)

1
0
0 2 4 6 8 10
nx
folded sequence
5

4
3
x(nx)

2
1
0
-5 -4 -3 -2 -1 0
nx

BS LAB DEPT OF ECE


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

Amplified/Attenuated signals:
input sequence
20
amplitude

10

0
1 2 3 4 5 6 7
n
amplified input sequence
100
amplitude

50

0
1 2 3 4 5 6 7
n
attenuated input sequence
4
amplitude

0
1 2 3 4 5 6 7
n

Right/Left shifting of Signals:


input sequence
2
h(n)

-2
0 0.5 1 1.5 2 2.5 3 3.5 4
n
right shifted sequence
2
h(n)

-2
2 2.5 3 3.5 4 4.5 5 5.5 6
n
left shifted sequence
2
h(n)

-2
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
n

BS LAB DEPT OF ECE


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

EXPERIMENT NO-4

FINDING EVEN AND ODD PART OF THE SIGNAL AND


SEQUENCE AND ALSO FIND REAL AND IMAGINARY
PARTS OF SIGNAL AND ENERGY, POWER SIGNALS

AIM:
Finding even and odd part of the signal and sequence and also find
real and imaginary parts of signal and energy, power signals.

SOFTWARE REQUIRED:

MATLAB R2013a (8.1 Version).

THEORY:
Even and odd part of a signal:
Any signal x(t) can be expressed as sum of even and odd components e
X(t)=xe(t)+xo(t)

Energy:
E=sum(abs(X).^2)

Average power:
P= (sum(abs(X).^2))/ length(x)

BS LAB DEPT OF ECE


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

PROGRAMME:
%programme for energy signal using sequence.
clc;
clear all;
close all;
x=[1 2 3 2];
n=length(x);
e1=0;
for i=1:n;
e1=e1+(x(i)*x(i));
end
%program for energy of a signal
t1=0:pi:10*pi;
z2=cos(2*pi*50*t1).^2;
e2=sum(abs(z2).^2);
%programme for power signal using sequence.
p1=(sum(abs(x).^2))/length(x);
%program for power of a signal
p2=(sum(abs(z2).^2))/length(z2);
%Even and odd parts of a signal
t2=0:.005:4*pi;
x=sin(t2)+cos(t2); % x=sint(t2)+cos(t2)
subplot(2,2,1)
plot(t2,x,'r','linewidth',2);
xlabel('t');
ylabel('amplitude')
title('input signal')
y=sin(-t2)+cos(-t2); % y=x(-t2)
subplot(2,2,2)
plot(t2,y,'g','linewidth',2);
xlabel('t2');
ylabel('amplitude')
title('input signal with t=-t2')
z=x+y;
subplot(2,2,3)

BS LAB DEPT OF ECE


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

plot(t2,z/2,'m','linewidth',2)
xlabel('t');
ylabel('amplitude')
title('even part of the signal')
p=x-y;
subplot(2,2,4)
plot(t2,p/2,'y','linewidth',2)
xlabel('t');
ylabel('amplitude');
title('odd part of the signal');
figure;
%Even and odd parts of a sequence
z=[0,2+j*4,3+j*2,5-j*1,-2-j*4,-j*3,0];
n=-3:3;
subplot(2,1,1);
stem(n,real(z),'g','linewidth',2); % real part
xlabel('n');
ylabel('amplitude');
title('real part of the complex sequence');
subplot(2,1,2);
stem(n,imag(z),'b','linewidth',2); % imaginary part
xlabel('n');
ylabel('amplitude');
title('imaginary part of the complex sequence');
figure;
%complex conjugate of a signal
zc=conj(z);
zc_folded= fliplr(zc);
zc_even=0.5*(z+zc_folded);
zc_odd=0.5*(z-zc_folded);
subplot(2,2,1);
stem(n,real(zc_even),'b','linewidth',2);
xlabel('n');
ylabel('amplitude');
title('real part of the even sequence');

BS LAB DEPT OF ECE


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

subplot(2,2,2);
stem(n,imag(zc_even),'g','linewidth',2);
xlabel('n');
ylabel('amplitude');
title('imaginary part of the even sequence');
subplot(2,2,3);
stem(n,real(zc_odd),'y','linewidth',2);
xlabel('n');
ylabel('amplitude');
title('real part of the odd sequence');
subplot(2,2,4);
stem(n,imag(zc_odd),'m','linewidth',2);
xlabel('n');
ylabel('amplitude');
title('imaginary part of the odd sequence');

RESULT:

various signal operations are observed

Result :

Energy signal using sequence

e1 = 18

Energy signal

e2 =4.0388

Power signal using sequence

p1 =4.5000

Power signal

p2 = 0.3672

BS LAB DEPT OF ECE


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

Result of even and odd signals

input signal input signal with t=-t2


2 2

1 1
amplitude

amplitude
0 0

-1 -1

-2 -2
0 5 10 15 0 5 10 15
t t2
even part of the signal odd part of the signal
1 1

0.5 0.5
amplitude

amplitude
0 0

-0.5 -0.5

-1 -1
0 5 10 15 0 5 10 15
t t

Result of real and imaginary part of signals.


real part of the complex sequence
6

4
amplitude

-2
-3 -2 -1 0 1 2 3
n
imaginary part of the complex sequence
4

2
amplitude

-2

-4
-3 -2 -1 0 1 2 3
n

BS LAB DEPT OF ECE


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

Result of real and imaginary parts using sequence


real part of the evensequence imaginary part of the even sequence
5 4
4 2

amplitude
amplitude

3
0
2
-2
1
0 -4
-5 0 5 -5 0 5
n n
real part of the odd sequence imaginary part of the odd sequence
4 0.5

2
amplitude

amplitude 0
0
-0.5
-2

-4 -1
-5 0 5 -5 0 5
n n

BS LAB DEPT OF ECE


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

EXPERIMENT NO-5

SAMPLING THEOREM VERIFICATION

AIM:
Verify the sampling theorem.

SOFTWARE REQUIRED:

MATLAB R2013a (8.1 Version).


THEORY:
Sampling Theorem:

A bandlimited signal can be reconstructed exactly if it is sampled at a


rate At least twice the maximum frequency component in it." Figure 1 shows
a signal g(t) that is bandlimited.

Figure 1: Spectrum of bandlimited signal g(t)

The maximum frequency component of g(t) is fm. To recover the


signal g(t) exactly from its samples it has to be sampled at a rate fs ≥ 2fm.

The minimum required sampling rate fs = 2fm is called ' Nyquist rate
Proof:
Let g(t) be a bandlimited signal whose bandwidth is fm (wm = 2πfm).

Figure 2: (a) Original signal g(t) (b) Spectrum G(w)

BS LAB DEPT OF ECE


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

δ (t) is the sampling signal with fs = 1/T > 2fm.

Figure 3: (a) sampling signal δ (t) ) (b) Spectrum δ (w)

Figure 4: (a) sampled signal gs(t) (b) Spectrum Gs(w)

To recover the original signal G(w):


1. Filter with a Gate function, H2wm(w) of width 2wm
Scale it by T.

Figure 5: Recovery of signal by filtering with a fiter of width 2wm

BS LAB DEPT OF ECE


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

Aliasing ws < 2wm.

Figure 6: Aliasing due to inadequate sampling

Aliasing leads to distortion in recovered signal. This is the reason why


sampling frequency should be atleast twice thebandwidth of the
signal.

Oversampling ws >2wm. This condition avoid aliasing.

Figure 7: Oversampled signal-avoids aliasing

PROGRAMME:
clc;
clear all;
close all;
t=-10:.01:10;
T=4;
fm=1/T;
x=cos(2*pi*fm*t);
subplot(2,2,1);
plot(t,x,'r','linewidth',2);
xlabel('time');
ylabel('x(t)');
title('continous time signal');
grid;
n1=-4:1:4;

BS LAB DEPT OF ECE


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

fs1=1.6*fm;fs2=2*fm;fs3=8*fm;
x1=cos(2*pi*fm/fs1*n1);
subplot(2,2,2);
stem(n1,x1,'g','linewidth',2);
xlabel('time');
ylabel('x(n)');
title('discrete time signal with fs<2fm');
hold on;
subplot(2,2,2);
plot(n1,x1,'b','linewidth',2);
grid;
n2=-5:1:5;
x2=cos(2*pi*fm/fs2*n2);
subplot(2,2,3);
stem(n2,x2,'y','linewidth',2);
xlabel('time');
ylabel('x(n)');
title('discrete time signal with fs=2fm');
hold on;
subplot(2,2,3);
plot(n2,x2,'m','linewidth',2)
grid;
n3=-20:1:20;
x3=cos(2*pi*fm/fs3*n3);
subplot(2,2,4);
stem(n3,x3,'r','linewidth',2);
xlabel('time');
ylabel('x(n)');
title('discrete time signal with fs>2fm')
hold on;
subplot(2,2,4);
plot(n3,x3)
grid;

RESULT:

Sampling theorem is verified.

BS LAB DEPT OF ECE


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

Result :

continous time signal discrete time signal with fs<2fm


1 1

0.5 0.5

x(n)
x(t)

0 0

-0.5 -0.5

-1 -1
-10 0 10 -5 0 5
time time
discrete time signal with fs=2fm discrete time signal with fs>2fm
1 1

0.5 0.5
x(n)

x(n)
0 0

-0.5 -0.5

-1 -1
-5 0 5 -20 0 20
time time

BS LAB DEPT OF ECE


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

Experiment No-06

FOURIER TRANSFORMS AND INVERSE FOURIER TRANSFORMS

AIM: -

To find Fourier transform and inverse Fourier transforms of given functions.

SOFTWARE REQURIED :-

MATLAB R2013a (8.1 Version).


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
PROGRAM:-

clc;
clear all;
close all;
syms t s;
syms w real;
syms A real;
syms o real;
syms b float;

% Fourier Transform

f=dirac(t);
F=fourier(f);
disp('The fourier transform of F =');
disp(F);
f1=A*heaviside(t);
F1=fourier(f1);
disp('The fourier transform of F1 =');
disp(F1);
f2=A*exp(-t)*heaviside(t);
F2=fourier(f2);

BS LAB DEPT OF ECE


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

disp('The fourier transform of F2 =');


disp(F2);
f3=A*t*exp(-b*t)*heaviside(t);
F3=fourier(f3);
disp('The fourier transform of F3 =');
disp(F3);
f4=sin(o*t);
F4=fourier(f4);
disp('The fourier transform of F4 =');
disp(F4);

%Inverse Fourier transforms.

F1=A*pi*(dirac(w-o)+dirac(w+o));
f1=ifourier(F1,t);
disp('The inverse fourier transform f1 =');
disp(f1);
F2=A*pi*(dirac(w-o)-dirac(w+o))/i;
f2=ifourier(F2,t);
disp('The inverse fourier transform f2 =');
disp(f2);
F3=A/(1+i*w);
f3=ifourier(F3,t);
disp('The inverse fourier transform f3 =');
disp(f3);
F4=(3*i*w+14)/((i*w)^2+7*i*w+12);
f4=ifourier(F4,t);
disp('The inverse fourier transform f4 =');
disp(f4);

Results:
The fourier transform of F =
1

The fourier transform of F1 =


A*(pi*dirac(w) - i/w)

The fourier transform of F2 =


A/(1 + w*i)

BS LAB DEPT OF ECE


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

The fourier transform of F3 =


-A*((sign(Re(b))/2 - 1/2)*transform::fourier(t/exp(b*t), t, -w) - 1/(b + w*i)^2)

The fourier transform of F4 =


-pi*(dirac(o - w) - dirac(o + w))*i

The inverse fourier transform f1 =


(A*(1/exp(o*t*i) + exp(o*t*i)))/2

The inverse fourier transform f2 =


(A*(1/exp(o*t*i) - exp(i*o*t))*i)/2

The inverse fourier transform f3 =


(A*heaviside(t))/exp(t)

The inverse fourier transform f4 =


((6*pi*dirac(t))/exp(3*t) - (6*pi*dirac(t))/exp(4*t) +
(10*pi*heaviside(t))/exp(3*t) - (4*pi*heaviside(t))/exp(4*t))/(2*pi)

BS LAB DEPT OF ECE


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

Experiment No-7

GIBBS PHENOMENON

AIM: - To write a MATLAB program to construct the following p periodic signal


represented by its Fourier series by considering different terms.

SOFTWARE REQURIED :-

MATLAB R2013a (8.1 Version).


. 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

THEORY:

The Gibbs phenomenon, the Fourier series of a piecewise continuously


differentiable periodic function behaves at a jump discontinuity. The n the
approximated function shows amounts of ripples at the points of discontinuity. This is
known as the Gibbs Phenomena. partial sum of the Fourier series has large oscillations
near the jump, which might increase the maximum of the partial sum above that of the
function itself. The overshoot does not die out as the frequency increases, but
approaches a finite limit. The Gibbs phenomenon involves both the fact that Fourier
sums overshoot at a jump discontinuity, and that this overshoot does not die out as the
frequency increases.

PROGRAM:-

clc;
clear all;
close all;
N=input('enter different types of harmonics=');
for i=1:N
n_har=input('enter the no. of harmonics in each
signal=');
t=-1:0.001:1;
omega_0=2*pi;
x=0;
for n=1:2:n_har
b_n=2/(n*pi);

BS LAB ECE DEPARTMENT


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

x=x+b_n*sin(n*omega_0*t);
end
hold on;
subplot(N,1,i);
plot(t,x,'b','linewidth',2);
xlabel('time--->');
ylabel('amp---->');
axis([-1 1 -0.5 1.5]);
text(0.55,1.0,['no.of har=',num2str(n_har)]);
end

RESULT:-
The operation of Gibbs Phenomenon is successfully completed.

OUTPUT:-

enter the no. of signals to reconstruct=4


enter the no. of harmonics in each signal=[5,10,25,60]

BS LAB ECE DEPARTMENT


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

BS LAB ECE DEPARTMENT


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

Experiment No -8
CONVOLUTION OF TWO SEQUENCES

AIM: - To write a MATLAB program to find the convolution of two sequences.

SOFTWARE REQURIED :-

MATLAB R2013a (8.1 Version).


.
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

PROGRAM:-

clc;
clear all;
close all;
n=0:8;
x1=1;
x2=0;
y1=x1.*(n>=0 & n<=2)+x2.*(n>=2 & n<=8);
subplot(2,2,1);
stem(n,y1);
xlabel('time n ---- >');
ylabel('amplitude --- >');
title('the sequence y1[n]')
y2=x1.*(n>=0 & n<=4)+x2.*(n>=4 & n<=8);
subplot(2,2,2);
stem(n,y2);
xlabel('time n ---- >');
ylabel('amplitude --- >');
title('the sequence y2[n]')
y=conv(y1,y2);
BS LAB ECE DEPARTMENT
TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

L=length(y);
n=0:L-1;
subplot(2,2,[3,4]);
stem(n,y);
xlabel('time n ---- >');
ylabel('amplitude --- >');
title('the convolution sequence of y1[n]&y2[n]');

RESULT:-

Thus the MATLAB Program to finding the convolution of two sequences


is completed successfully.

OUTPUT:-

BS LAB ECE DEPARTMENT


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

Experiment No-9
AUTO-CORRELATION & CROSS-CORRELATION BETWEEN SIGNALS

AIM: - To write a matlab program to compute autocorrelation and cross


correlation between signals.

SOFTWARE REQURIED :-

MATLAB R2013a (8.1 Version).


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
PROGRAM: window
clc;
clear all;
close all;
t=0:0.01:1;
f1=3;
x1=sin(2*pi*f1*t);
figure;
subplot(2,1,1);
plot(t,x1);
title('sine wave');
xlabel('time ---- >');
ylabel('amplitude--- >');
grid;
[rxx lag1]=xcorr(x1);
subplot(2,1,2);
plot(lag1,rxx);
grid;
title('auto-correlation function of sine wave');
figure;
subplot(2,2,1);

BS LAB ECE DEPARTMENT


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

plot(t,x1);
title('sine wave x1');
xlabel('time ---- >');
ylabel('amplitude --- >');
grid;
f2=2;
x2=sin(2*pi*f2*t);
subplot(2,2,2);
plot(t,x2);
title('sine wave x2');
xlabel('time ---->');,ylabel('amplitude --- >');
grid;
[cxx lag2]=xcorr(x1,x2);
subplot(2,2,[3,4]);
plot(lag2,cxx);
grid;
title('cross-correlation function of sine wave');

RESULT:
Thus the MATLAB Program of computing auto correlation and cross
correlation between signals was completed successfully.

OUTPUT:

BS LAB ECE DEPARTMENT


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

BS LAB ECE DEPARTMENT


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

Experiment no-10

EXTRACTION OF PERIODIC SIGNAL MASKED


BY NOISE USING CORRELATION.

AIM: -
To write a program to extract the periodic signal masked by Noise
using Auto correlation and Cross Correlation method.

SOFTWARE REQURIED :-
MATLAB R2013a (8.1 Version).
.
PROCEDURE:-
Open MATLAB Software
Open new M-file
Type the program
Save in current directory
Run the program
For the output see command window\ Figure window.

PROGRAM:-
clc;
clear all;
close all;
t=0:0.01:10;
s=cos(2*pi*3*t)+sin(2*pi*5*t); % periodic signal
figure;
subplot(2,1,1);
plot(t,s);
xlabel(' t ---- >') ;
ylabel(' amp --- > ');
title('the periodic signal');
L=length(t);
n=randn(1,L); % noise signal
subplot(2,1,2);
plot(t,n);
xlabel(' t ---- >') ;
ylabel(' amp --- > ');
title('the noise signal');
BS LAB ECE DEPARTMENT
TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

L=length(t);
f=s+n; % received signal
figure;
subplot(2,1,1);
plot(t,f);
xlabel(' t ---- >');
ylabel(' amp --- > ');
title('the received signal');
rxx=xcorr(f,s,200);
subplot(2,1,2);
plot(rxx);
title('the Correlator output');

RESULTS: -
Thus the MATLAB Program to detect the periodic signal masked by
noise using Auto Correlation &Cross Correlation method is performed.

OUTPUT

BS LAB ECE DEPARTMENT


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

BS LAB ECE DEPARTMENT


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

Experiment No-11(a)

LINEAR SYSTEM OR NON-LINEAR SYSTEM

AIM: -
To write a matlab program to verify the given system is linear or non-
linear.

SOFTWARE REQURIED :-
MATLAB R2013a (8.1 Version).

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
PROGRAM:-

clc;
clear all;
close all;
x1=input('enter the x1[n] sequence=');
x2=input('enter the x2[n] sequence=');
if length(x1)~=length(x2)
disp(' length of x2 must be equal to the length of x1');
return;
end;
h=input('enter the h[n] sequence=');
a=input('enter the constant a= ');
b=input('enter the constant b= ');
y01=conv(a*x1,h);
y02=conv(b*x2,h);
y1=y01+y02;
x=a*x1+b*x2;

BS LAB ECE DEPARTMENT


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

y2=conv(x,h);
L=length(x1)+length(h)-1;
n=0:L-1;
subplot(2,1,1);
stem(n,y1);
label('n --->'); label('amp --- >');
title('sum of the individual response');
subplot(2,1,2);
stem(n,y2);
xlabel('n --->'); ylabel('amp --- >');
title('total response');
if y1==y2
disp('the system is a Linear system');
else
disp('the system is a non-linear system');
end;

RESULT:-
Thus the MATLAB Program of verifying the system is linear or
non linear by using matlab has performed.

INPUT SEQUENCE:
Enter the x1[n] sequence= [0 2 4 6]
Enter the x2[n] sequence= [3 5 -2 -5]
Enter the h[n] sequence= [-1 0 -3 -1 2 1]
Enter the constant a= 2 & enter the constant b= 3

The system is a linear system

BS LAB ECE DEPARTMENT


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

OUTPUT:-

BS LAB ECE DEPARTMENT


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

Experiment No-11(b)

TIME-INVARIANT OR TIME-VARIANT SYSTEM

AIM: - To write a matlab program to verify the given system is Time –invariant
or Time–variant.

SOFTWARE REQURIED :-

MATLAB R2013a (8.1 Version).


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

PROGRAM:-

clc;
clear all;
close all;
x=input('enter the sequence x[n]=');
h=input('enter the sequence h[n]=');
d=input('enter the positive number for delay d=');
xdn=[zeros(1,d),x]; % delayed input
yn=conv(xdn,h); % output for delayed input
y=conv(x,h); % actual output
ydn=[zeros(1,d),y]; % delayed output
figure;
subplot(2,1,1);
stem(0:length(x)-1,x);
xlabel('n ---->'),ylabel('amp --->');
title('the sequence x[n] ');
subplot(2,1,2);
stem(0:length(xdn)-1,xdn);
BS LAB ECE DEPARTMENT
TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

xlabel('n ---->'),ylabel('amp --->');


title('the delayed sequence of x[n] ');
figure;
subplot(2,1,1);
stem(0:length(yn)-1,yn);
xlabel('n ---->'),ylabel('amp --->');
title('the response of the system to the delayed sequence of x[n] ');
subplot(2,1,2);
stem(0:length(ydn)-1,ydn);
xlabel('n ---->'),ylabel('amp --->');
title('the delayed output sequence ');
if yn==ydn
disp('the given system is a Time-invarient system');
else
disp('the given system is a Time-varient system');
end;

RESULT:-
Thus the MATLAB Program of verifying the system is Time –
invariant or Time–variant System by using matlab has performed.

INPUT SEQUENCE:
Enter the sequence x[n] = [0 2 3 1 -2 7 3]
Enter the sequence h[n] = [4 -5 -11 -3 7 2 6 8 -15]
Enter the positive number for delay d=5

The given system is a Time-invariant system

BS LAB ECE DEPARTMENT


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

OUTPUT:-

BS LAB ECE DEPARTMENT


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

Experiment No-12

LOCATING THE ZEROS AND POLES AND PLOTTING THE POLE-


ZERO MAPS IN S-PLANE AND Z-PLANE FOR THE GIVEN TRANSFER
FUNCTION
AIM: - To Locate the zeros and poles and plotting the pole-zero maps in S-plane and Z-plane
for the given transfer function.

SOFTWARE REQURIED :-

MATLAB R2013a (8.1 Version).


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

BS LAB ECE DEPARTMENT


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

PROGRAM:-
Location of poles and zeros in the S plane
clear all;
close all;
clc;
num = input('Enter the numerator coefficients .... :: ');
den = input('Enter the denominator coefficients .....:: ');
H = tf(num, den)
poles = roots(den)
zeros = roots(num)
sgrid
pzmap(H)
grid on
title('Pole/Zero Plot for Complex Poles and Zeros in S plane');

OUTPUT
Enter the numerator coefficients .... :: [1 2.5]
Enter the denominator coefficients .... :: [1 6 11 6]
Transfer function:
s + 2.5

s^3 + 6 s^2 + 11 s + 6
poles =
-3.0000
-2.0000
-1.0000
zeros =
-2.5000

Location of poles and zeros in the Z plane


clc;
clear all;
close all;
num = input('Enter the numerator coefficients .... :: ');
den = input('Enter the denominator coefficients .....:: ');
p = roots(den)
z = roots(num)
zplane(z,p);
title('Pole/Zero Plot for Complex Poles and Zeros in Z plane');
BS LAB ECE DEPARTMENT
TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

OUTPUT
Enter the numerator coefficients .... :: [1 2.5]
Enter the denominator coefficients .... :: [1 6 11 6]
p=
-3.0000
-2.0000
-1.0000
z=
-2.5000

BS LAB ECE DEPARTMENT


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

PROGRAM 2:
Plotting pole-zero maps in s-plane and z-plane
%Stability of LTI system in s-plane
clc;
num=input('type the numerator vector');
den=input('type the denominator vector');
H=tf(num,den);
[p,z]=pzmap(H);
disp('zeros are at');
disp(z);
disp('poles are at');
disp(p);
figure;
pzmap(H);
[r,p,k]=residue(num,den);
disp('PFE coefficients');%Partial Fraction Expansion coefficients
disp(r);
disp('Gain constant is');
disp(k);
if max(real(p))>=1
disp('All poles do not lie in left half of s-plane');
disp('LTI system is not stable system');
else
disp('All poles lie in left half of s-plane');
disp('LTI system is stable system');
end;

BS LAB ECE DEPARTMENT


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

%%%Stability of LTI system in z-plane


clc;
num=input('type the numerator vector');
den=input('type the denominator vector');
H=filt(num,den);
z=zero(H);
disp('zeros are at');
disp(z);
disp('radius of zeros');
radzero=abs(z);
[r,p,k]=residuez(num,den);
disp('poles are at');
disp(p);
disp('radius of poles');
radpole=abs(p);
disp(radpole);
figure;
disp('PFE coefficients');%Partial Fraction Expansion coefficients
disp(r);
disp('Gain constant is');
disp(k);
zplane(num,den);
if max(radpole)>=1
disp('All poles do not lie in z plane');
disp('LTI system is not stable system');
else
disp('All poles lie in z plane');
disp('LTI system is stable system');
end;

BS LAB ECE DEPARTMENT


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

BS LAB ECE DEPARTMENT


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

Experiment No-13

Laplace transform & Inverse Laplace transform

AIM:
Finding the Laplace transform & Inverse Laplace transform of some
signals.

SOFTWARE REQURIED :-

MATLAB R2013a (8.1 Version).


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
THEORY: window
Laplace transforms:
The Laplace transform of a signal f(t) can be defined as follows:

Inverse Laplace transform


The inverse Laplace transform is given by the following formula :

PROGRAM:-
clc;
clear all;
close all;
%representation of symbolic variables
syms f t w s;

%laplace transform of t
f=t;
z=laplace(f);
disp('the laplace transform of f = ');
disp(z);

BS LAB ECE DEPARTMENT


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

% laplace transform of sin signal


f1=sin(w*t);
f2=sin(w*(t-1));
v1=laplace(f1);
disp('the laplace transform of f1 = ');
disp(v1);
v2=laplace(f2);
disp('the laplace transform of f2 = ');
disp(v2);
simplify(v2)

%inverse laplace transform


y1=ilaplace(z);
disp('the inverse laplace transform of z = ');
disp(y1);
y2=ilaplace(v1);
disp('the inverse laplace transform of v1 = ');
disp(y2);
y3=ilaplace(v2);
disp('the inverse laplace transform of v2 = ');
disp(y3);
x1=11*s^3+52*s^2+86*s+72;
x2=4*s*(s+2)^2*(s+3);
x3=x1/x2;
y4=ilaplace(x3);
disp('the inverse laplace transform of x3 = ');
disp(y4);

RESULT:-
Hence Laplace transform verified
Output:
The laplace transform of f = 1/s^2
The laplace transform of f1 = w/(s^2+w^2)
The laplace transform of f2 = cos(w)*w/(s^2+w^2)-sin(w)*s/(s^2+w^2)

ans =-(-cos(w)*w+sin(w)*s)/(s^2+w^2)

The inverse laplace transform of z = t


The inverse laplace transform of v1 = sin(w*t)
The inverse laplace transform of v2 = sin(w*t)*cos(w)-cos(w*t)*sin(w)
The inverse laplace transform of x3 =-5/2*t*exp(-2*t)+5/4*exp(-3*t)+3/2

BS LAB ECE DEPARTMENT


TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

Experiment No-14

WIENER- KHINTCHINE RELATION

AIM: -
To write a matlab program to verify the wiener-khintchine relation.

SOFTWARE REQURIED :-
MATLAB R2013a (8.1 Version).

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
PROGRAM:-

clc;
clear all,
t=0:0.1:2*pi;
x=sin(2*t);
subplot(3,2,1)
plot(x);
au=xcorr(x,x);
subplot(3,2,2);
plot(au);
title('autocorrelation of x');
v=fft(au);
subplot(3,2,3);
plot(abs(v));
title('psd of x');
y=ifft(v);
subplot(3,2,4);
plot(y);
title('ifft of psd');

RESULT:-
Thus the MATLAB Program of verifying the wiener-khintchine
relation using matlab has performed.

BS LAB ECE DEPARTMENT


EXPERIMENT NO-15
REMOVING OF NOISE BY
AUTOCORRELATION/CROSSCORRELATION IN GIVEN SIGNAL
CORRUPTED BY NOISE

AIM:
Removal of noise by auto correlation/cross correlation in a given signal
corrupted by noise using MATLAB.

SOFTWARE REQUIRED:

MATLAB R2013a (8.1 Version).

PROGRAMME:

clear all;
close all;
clc;
N= input('Enter the number of samples ......:: ');
h=1/N;
x=0:h:1;
y=sin(3*pi*x);
subplot(4,1,1);
plot(x,y);
xlabel('-- > time'); ylabel('-> Amplitude');
title('Original signal');
w=rand(1,N+1);
subplot(4,1,2);
plot(x,w);
xlabel('-- > time'); ylabel('-> Amplitude');
title('Noise');
k=y+w;
subplot(4,1,3);
plot(x,k);
xlabel('-- > time'); ylabel('-> Amplitude');
title('Signal+noise');
m=xcorr(k,100);
subplot(4,1,4)
plot(x,0.01*m(1:N+1));
xlabel('---> time'); ylabel('-> Amplitude');
title('Recovered signal');

OUTPUT

Enter the number of samples ..... :: 100


Enter the number of cycles ..... :: 4
TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

EXPERIMENT NO-16
Generation of Gaussian noise, Computation of its mean, M.S.value and
its skew, kurtosis, PSD and Probability Distribution Function

AIM:
Generate Gaussian noise, Computation of its mean, M.S.value and its skew,
kurtosis, PSD using MATLAB.

SOFTWARE REQUIRED:

MATLAB R2013a (8.1 Version).

PROGRAMME:

clc;
clear all;
close all;
N= input(' Enter the number of samples.....:: ');
R1=randn(1,N);
M=mean(R1)
K=kurtosis(R1)
P=periodogram(R1);
V=var(R1)
x = psd(R1);
subplot(2,2,1);
plot(R1);
title('Normal [Gaussian] Distributed Random
Signal');
xlabel('Sample Number');
ylabel('Amplitude');
subplot(2,2,2);
hist(R1);
title('Histogram [Pdf] of a normal Random
Signal');
xlabel('Sample Number');
ylabel('Total');
BS LAB DEPT OF ECE
TKR COLLEGE OF ENGINEERING AND TECHNOLOGY

subplot(2,2,[3,4]);
plot(x);
title('PSD of a normal Random Signal');
xlabel('Sample Number');
ylabel('Amplitude');

OUTPUT

Enter the number of samples .... :: 512


M=
-0.0398
K=
3.0770
V=
0.9535

BS LAB DEPT OF ECE

You might also like