BS Lab Manual - Student Copy - AY-2016-17 PDF
BS Lab Manual - Student Copy - AY-2016-17 PDF
BS Lab Manual - Student Copy - AY-2016-17 PDF
DEPARTMENT OF
ELECTRONICS AND COMMUNICATIONS ENGINEERING
Prepared By
BACHU SRINIVAS
Associate Professor
Department of ECE
D. NARESH
Assistant Professor
Department of ECE
III. HIGHLIGHTS:
Teaching methodology involves technical case studies, creative exercises,
online assignments & descriptive tests.
E-Class rooms.
Industry focused knowledge is imparted by R & D and Industry peer
members.
Digital Library.
Tie up with MNC companies and foreign Universities.
State of art laboratories, sophisticated equipment and advanced
software.
Library is equipped with National and International Journals, 50000
volumes and more than 7500 titles of books, NPTEL, SONET CDs and
internet lab for students and staff.
IEEE online journals and IEL online journals through AICTE INDEST
CONSORTIUM.
Wi-Fi campus with 12 Mbps bandwidth.
MAT LAB, PSPICE, VHDL, TINAPRO and DSP software‟s are available.
State of art English Language lab and 800 computers connected with
dedicated high- end servers.
Scholarship and free books for meritorious students.
Book Bank Scheme facility to the students.
Most of the classrooms are fixed with LCDs and screens.
All major professional societies‟ student chapters like ISTE, IETE and
IEEE etc.
IV. FACULTY
The faculty in the department consists of Senior and well experienced
Professors, Associate Professors and Assistant Professors with Ph. D. / M.
Tech qualifications. An experienced System Administrator and well-qualified
Lab staff support the conduct of Laboratories
PEO1. Graduates shall have the ability to apply knowledge across the
disciplines and in emerging areas of Electronics and Communications
Engineering for higher studies, research, employability and handle the
realistic problems.
PROGRAMME OUTCOMES
The following list of program outcomes describes what graduates are expected
to know and be able to do at the time of graduation. Graduates at graduation
will have:
A. An ability to apply knowledge of mathematics, science, and engineering
B. An ability to design and conduct experiments, as well as to analyze and
interpret data
C. An ability to design a system, component, or process to meet desired
needs within realistic constraints such as economic, environmental, social,
political, ethical, health and safety, manufacturability and sustainability.
D. An ability to function on multidisciplinary teams.
E. An ability to identify, formulate and solve engineering problems.
F. An understanding of professional and ethical responsibility.
G. An ability to communicate effectively.
H. The broad education necessary to understand the impact of engineering
solutions in a global, economic, environmental, and societal context.
I. An recognition of the need for, and an ability to engage in life-long
learning.
J. A knowledge of contemporary issues.
K. An ability to use the techniques, skills, and modern engineering tools
necessary for engineering practice.
L. An in-depth ability to use a combination of Software, Hardware and
experimental techniques practiced in circuits, physical electronics,
communication, networks, systems and programming.
MAPPING of PEOs and POs:
Progra Progrmme Outcomes
mme
Educa
tional A B C D E F G H I J K L
Object
ives
PEO 1 √ √ √ √
PEO 2 √ √ √ √ √ √
PEO 3 √ √ √ √ √ √ √ √ √ √
LIST OF EXPERIMENTS
Gibbs phenomenon.
9 73
Finding the Fourier transform of a given signal and
10 plotting its magnitude and phase spectrum. 75
ADDITIONAL PROGRAMS
Introduction
MATLAB is a mathematical software package, which is used extensively in
academia and industry and stands for MATrix LABoratory. It is one of the
leading scientific and technical computing soft ware‟s, used by over 10,20,000
engineers and scientists in more than 100 countries, on all seven continents.
Control Systems
Analog Communications
Digital signal Processing
VLSI Design
Digital Communications
Digital Image Processing
Satellite Communications
Wireless Communications
Embedded Systems
Artificial Neural Networks
It provides several optional „toolboxes‟ such as statistical toolbox, Control
systems toolbox, Neural Networks toolbox, symbolic math tool box, Signal
Processing toolbox, etc., which are extremely useful for specific applications.
Each toolbox provides a set of functions written for a specific application
Starting MATLAB
To start MATLAB, double-click the MATLAB shortcut icon on your Windows
desktop.
MATLAB Desktop
When you start MATLAB, the MATLAB desktop appears as shown inn figure
1, containing tools (graphical user interfaces) for managing files, variables,
and applications associated with MATLAB.
Ensure first that the current directory is the one that is your own ,which can
be done either by typing the following command at the command prompt or
using the „view or change the current directory‟ option
>> cd E:\slab
EXPERIMENT 1
BASIC OPERATIONS ON MATRICES
Variables
>>x=3+4
Creates a variable and assigns a value 7 to it
Expressions and Statements
MATLAB can be used as a simple calculator
>>34/7
>>log(12)
>>y=sqrt(17)
>>a=3+ 4*j
>>b=abs(a)
Entering Matrices
•Separate the elements of a row with blanks or commas.
•Use a semicolon, ; , to indicate the end of each row.
•Surround the entire list of elements with square brackets, [ ].
To enter a matrix, simply type in the Command Window
A = [16 3 2 13; 5 10 11 8; 9 6 7 12; 4 15 14 1]
MATLAB displays the matrix you just entered.
A=
16 3 2 13
5 10 11 8
9 6 7 12
4 15 14 1
Sum, Transpose, and diag
ans =
34 34 34 34
>>A‟
ans =
16 5 9 4
3 10 6 15
2 11 7 14
13 8 12 1
And
>>sum(A')'
produces a column vector containing the row sums
ans =
34
34
34
34
The sum of the elements on the main diagonal is easily obtained with the help
of the diag function, which picks off that diagonal.
>>diag(A)
produces
ans =
16
10
7
1
and
sum(diag(A))
produces
ans =
34
>>diag(A)
Subscripts
The element in row i and column j of A is denoted by A(i,j). For example,
A(4,2) is the number in the fourth row and second column.
The Colon Operator
The colon, :, is one of MATLAB‟s most important operators. It occurs in
several
different forms. The expression
1:10
is a row vector containing the integers from 1 to 10
1 2 3 4 5 6 7 8 9 10
Operations on Vectors
Let a=[5 2 1 4 3] , b=[ 8 6 7]
MATLAB
Meaning Example
Function
min Smallest element min (a) = 1
Arithmetic
Operator Operation
+ Addition
- Subtraction
* Matrix Multiplication
.* Array Multiplication
/ Division
^ Matrix Power
.^ Array Power
' Transpose
Relational Operators
= = Equal
~ = Not Equal
< Less Than
< = Less Than or Equal
> Greater Than
> = Greater Than or Equal
Matrix Functions
Eye Identity matrix
zeros Matrix of zeros
ones Matrix of ones
EXPERIMENT 2
GENERATION OF VARIOUS SIGNALS AND SEQUENCES (PERIODIC
AND APERIODIC), SUCH AS UNIT IMPULSE, UNIT STEP, SQUARE,
SAW TOOTH, TRIANGULAR, SINUSOIDAL, RAMP, SINC
2(a) Unit Step Signal
Aim:
To generate unit step signal.
Software used:
1. Operating system-Windows XP
2. MATLAB R2009b
Theory:
Unit Step sequence:
The unit step function is that type of elementary function which exists
only for positive side and zero for negative side.
1, n 0
Un
0, otherwise
Program:
clc;
clear all;
close all;
n=[-5:0.5:5]; % Specifying the discrete time index n
x1=1;
x2=0;
u=x1.*(n>=0)+x2.*(n<0);
subplot(2,1,1);
stem(n,u,'b')
grid; % Sets the X Grid, Y Grid lines
axis([-5 5 -.2 1.2]); % sets scaling for the x- and y-axes
xlabel('time(n) ---->'); % adds text beside the X-axis
ylabel('U(n) ---->'); % adds text beside the Y-axis
title('Fig (a): Unit step sequence');
u=x1.*(t>=0)+x2.*(t<0);
subplot(2,1,2);
plot(t,u,'b')
grid; % Sets the X Grid, Y Grid lines
axis([-5 5 -0.2 1.2]); % sets scaling for the x- and y-axes
xlabel('time(t) ---->'); % adds text beside the X-axis
ylabel('U(t) ---->'); % adds text beside the Y-axis
title('Fig (b): Unit step signal ');
Output:
Result:
n, n 0
R n
0, otherwise
Program:
clc;
clear all;
close all;
r=x1.*(n>=0)+x2.*(n<0);
stem(n,r,'*');
grid;
axis([-5 5 -0.2 1.2]);
xlabel('time(n) ---->');
ylabel('R(n) ---->');
title('Fig (a): Unit ramp sequence‟);
Output:
Result:
n2
Pn 2 , n 0
0, otherwise
Program:
clc;
clear all;
close all;
x1=((n.^2)/2);
x2=0;
stem(n,p,'k');
grid;
Output:
Result:
1, n 0
n
0, otherwise
Program:
clc;
clear all;
close all;
n=[-5:0.5:5]; % Specifying the discrete time index n
x1=1;
x2=0;
ui=x1.*(n==0)+x2.*(n>0)+x2.*(n<0);
stem(n,ui,'b');
grid;
Result:
Output:
1, n 0
Sgnn 0, n 0
- 1, n 0
Program:
sig=x1.*(n>0)+x2.*(n==0)+x3.*(n<0);
stem(n,sig);
grid;
axis([-5 5 -1.2 1.2]);
xlabel('time(n) ---->');
ylabel('Sgn(n) ---->');
Result:
Output:
SinC(t)=Sin(π t)/
(π t)
Program:
clc;
clear all;
close all;
%% Sinc function (continuous case)
t=[-3:0.1:3];
x=sin(pi*t)./(pi*t);
subplot(1,2,1);
plot(t,x);
grid();
axis([-3 3 -0.4 1.2])
xlabel('----->time(t)');
ylabel('----->sinc(t)');
title('Fig a): Sinc function (continuous case)');
Result:
Aim: To generate the following periodic signals and sequences using MATLAB
software.
1. Sine 2. Saw tooth
3. Triangular 4. Square
Theory:
Sine Wave:
The sine wave or sinusoid is a mathematical curve that describes a smooth
repetitive oscillation. It is named after the function sine, of which it is the
graph as shown in Fig. 3(a). It‟s most basic form as a function of time (t) is:
X(t)=ASin(ωt)
Where, A is the Amplitude, is the peak deviation of the function from zero.
ω=2πf is the angular frequency is the rate of change of the function argument
in units of radians per second
f is the ordinary frequency, is the number of oscillations (cycles) that occur
each second of time.
3(b). As its name suggests, this waveform resembles the teeth of a saw. A saw
tooth wave generally goes upward like a hill and drops down sharply. It can
also go downwards and then rise up sharply. This form of wave is known as
"reverse saw tooth wave" or “inverse saw tooth wave”. A saw tooth wave
comprises infinite set of harmonically related sine waves. This wave is often
used in sound synthesis.
Saw-tooth Wave
Triangular Wave
A wave whose amplitude rises along a straight line to a given maximum, then
returns quickly to the baseline again following a linear path. Alternatively,
such a wave may rise quickly to a given peak, then drop gradually following a
linear path is as shown in Fig. 3(c).
Triangular Wave
Square Wave
A waveform that rises quickly to particular amplitude remains constant for a
time period and drops fast at the end as shown in Fig. 3(d). In digital systems,
square waves are the norm, because they represent a binary digit (0 or 1).
Square waves can also be generated in musical synthesizers and have a raspy
sound.
Square Wave
clc;
clear all;
close all;
N = input('Enter the number of cycles ...:: ');
t = 0:0.05:N; % Set time index 0 to N
subplot(1,2,1);
plot(t,x);
xlabel('---------> Time');
ylabel('---------> Amplitude');
title('a. Sinusoidal signal in continuous case');
subplot(1,2,2);
stem(t,x);
xlabel('---------> Time');
ylabel('---------> Amplitude');
title('b. Sinusoidal signal in discrete case‟');
Output:
clc;
clear all;
close all;
N = input('Enter the number of cycles ...:: ');
t1 = 0:25;
t = [];
for i = 1:N,
t = [t,t1];
end;
subplot(2,1,1);
plot(t);
xlabel('---------> Time');ylabel('---------> Amplitude');
title('a.Sawtooth waveform in continuous case');
subplot(2,1,2);
stem(t);
xlabel('---------> Time');ylabel('---------> Amplitude');
title('b.Sawtooth waveform in discrete case ');
Output:
t1 = 0:0.1:M/2;
t2 = M/2:-0.1:0;
t = [];
for i = 1:N,
t = [t,t1,t2];
end;
subplot(1,2,1);
plot(t);
xlabel('---------> Time');
ylabel('---------> Amplitude');
title('Triangular waveform');
subplot(1,2,2);
stem(t);
xlabel('---------> Time');
ylabel('---------> Amplitude');
title('Triangular waveform');
Output:
Enter the number of cycles .....:: 3
Enter the period ....:: 4
clc;
clear all;
close all;
t = 0 : 0.0001 : 0.1;
y = square ( 2 * pi * 50 * t);
plot(t , y);
grid;
axis ( [ 0 0.1 -2 2 ] );
xlabel('Time index t');
ylabel('Amplitude');
title('Square Wave Signal');
Output:
2(h) Generation of Saw tooth and Triangular waves using Saw tooth
Function
Aim:
To generate saw tooth wave signal.
Software used:
1. Operating system-Windows XP
2. MATLAB R2009b
Theory:
Repeating waveform that rises from zero to maximum value linearly drops
back to zero and repeats.
Program:
fs = 10000;
t = 0 : 1/fs : 1.5;
x = sawtooth (2 * pi * 100 * t);
plot( t , x ); axis ( [ 0 0.05 -1 1 ] );
xlabel('Time Index t (sec.)');
ylabel('Amplitude');
title ('Sawtooth Wave Signal Sequence');
Output:
Result:
Aim:
To generate a triangular wave signal.
Software used:
1. Operating system-Windows XP
2. MATLAB R2009b
Program:
fs = 10000;
t = 0 : 1/fs : 1.5;
x = sawtooth (2 * pi * 50 * t , 0.5);
plot(t,x); axis ( [ 0 0.1 -1 1 ] );
xlabel('Time Index t (sec.)');
ylabel('Amplitude');
title('Triangular Wave Signal Sequence');
Output:
Result:
Viva Questions:
Fig(c) Fig(d)
Fig(e)
***
EXPERIMENT-3
OBSERVATIONS ON SIGNALS AND SEQUENCES SUCH AS
ADDITION, MULTIPLICATION, SCALING, SHIFTING, FOLDING,
COMPUTATION OF ENERGY AND AVERAGE POWER
Program:
%% Addition and Multiplication of the two signals (sine and cosine signals)
clc;
clear all;
close all;
Ts=1/fs;
t=0:Ts:.003;
x1=sin(2*pi*fm*t);
subplot(2,2,1);
stem(t,x1,'filled');grid;
ylabel('Amplitude ---->')
subplot(2,2,3);
stem(t,x2','filled');
grid;
xlabel('Time (sec)')
ylabel('Amplitude')
subplot(2,2,2);
stem(t,ym,'*','r');grid();
ylabel('Amplitude ---->')
subplot(2,2,4);
stem(t,ya,'*','k');
grid;
ylabel('Amplitude ---->')
Output:
Enter the "fm" (Message freq) for the sine and cosine waves: 350
Result:
Scaling of a signal:
of x t , where K is a constant.
Program:
clc;
clear all;
close all;
fm=input('Enter the message frequency(fm) for generating sine wave is..::');
k=input('Enter the time scaling value(k)');
A=input('Enter the amplitude scaling value(A)');
subplot(2,2,1);
plot(t,x1);
axis([0 .2 -2 2]);grid();
xlabel('Time(sec) ---->');
ylabel('Amplitude ---->');
title('Fig(a): Sine wave without scaling')
subplot(2,2,2);
plot(t,x2,'r');
axis([0 0.2 -2 2]);grid;
xlabel('Time(sec) ---->');
ylabel('Amplitude ---->');
title('Fig(b): Sine wave with time scaling');
subplot(2,2,4);
plot(t,x3,'r');
axis([0 .2 -A-1 A+1]);
grid;
xlabel('Time(sec) ---->');
ylabel('Amplitude ---->');
title('Fig(c): Sine wave with amplitude scaling');
Output:
Enter the message frequency (fm) for generating sine wave is...: 100
Result:
Time Shifting:
delay results in shifting the original signal x t to right, to generate the time
shifted signal x t m .
Program:
clc;
clear all;
close all;
n=0:1:5;
h=[2,3,-4,3,2,-5]; % Generate the impulse sequence
subplot(2,2,1)
stem(n,h); % plot the impulse sequence
grid;
xlabel('----> n');ylabel('----> h(n)');
title('Fig(a): Impulse sequence');
subplot(2,2,3)
stem(n+rst,h); % plot the right side shifted sequence
grid;
xlabel('----> n');ylabel('----> h(n)');
title('Fig(b): Right side shifted sequence');
subplot(2,2,4)
stem(n-lst,h); % plot the left side shifted sequence
grid;
xlabel('----> n');
ylabel('----> h(n)');
title('Fig(c): Left side shifted sequence');
Output:
Result:
which is a mirror image of the original signal x t with respect to the time
origin t=0.
Program:
clc;
clear all;
close all;
t=[0:0.01:1];
A=4; % Assighn the apmlitude
f=5; % Create a 5 Hz sine wave lasting 1 sec
x=A*sin(2*pi*f*t);
lx=length(x);
tx=0:lx-1; % set arange for +ve X-axis
subplot(2,1,1);
plot(tx,x);
xlabel('----> tx');
ylabel('---> Amplitude');
title('Fig(a): Original signal')
subplot(2,1,2);
plot(tf,xf);
xlabel('----> nf');
ylabel('---> Amplitude');
title('Fig(b): Folded signal')
Output:
Result:
Program:
Output:
The calculated Energy E of the signal is
1.3333
Result:
Program:
clc;
clear all;
close all;
N = 10;
t = -N : 0.0001 : N;
x = cos (2 * pi * 50 * t ) .^ 2;
P = sum(abs(x).^2)/length(x);
BASIC SIMULATION LAB 49
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS (GNITC)
Output:
The calculated Power P of the signal is
0.3750
Result:
Viva Questions:
***
EXPERIMENT-4
EVEN AND ODD PARTS OF SIGNAL/SEQUENCE & REAL AND IMAGINARY
PARTS OF SIGNAL
4(a) Even and Odd parts of Signal/Sequence
Aim:
To find the even and odd & real and imaginary of the given
signal/sequence
Software used:
1. Operating system-Windows XP
2. MATLAB R2009b
Theory:
One of the characteristics of signal is symmetry that may be useful for signal
analysis. Even signals are symmetric around vertical axis, and Odd signals
are symmetric about origin.
1
X(t ) X(t ) 1 X(t ) X(t )
2 2
Where X e ( t )
1
X(t ) X(t ) , Xo (t ) 1 X(t ) X(t )
2 2
Example: sine function is odd signal and cosine function is even signal.
Program:
clc;
clear all;
close all;
t=[-3:0.1:3];
x1=exp(2*t);
x2=exp(-2*t); % Generae the time folded signal
subplot(2,2,1);
plot(t,x1);
subplot(2,2,2);
plot(t,x2);
axis([-3 3 ymin ymax]);
xlabel('-----> t');
ylabel('x2(t)');
title('Fig(b):Time folded Signal x(-t)');
subplot(2,2,3);
plot(t,xe);
axis([-3 3 ymin ymax]);
xlabel('-----> t');
ylabel('xe(t)');
title('Fig(c):Even part of x(t)');
subplot(2,2,4);
plot(t,xo);
axis([-3 3 ymin ymax]);
xlabel('-----> t');
ylabel('xo(t)');
title('Fig(d):Odd part of x(t)');
Output:
"The given signal is neither even nor odd signal"
Result:
Aim: To find the Real and Imaginary parts of the Exponential signal
1
i t
x(t ) Ae 12 6
Software used:
1. Operating system-Windows XP
2. MATLAB R2009b
Theory:
A signal can be represented as a vector with real (Re) and imaginary (Im)
components recorded from the I and Q channels respectively. An
equivalent/alternative representation of the signal is as a complex number.
rx= real(x);
ix=imag(x);
subplot (2,1,1);
plot(t,rx); % Plot Real part
xlabel('time index n ----->');
ylabel('Amplitude ----->');
title('Fig(a): Real part of the given sequence');
subplot (2,1,2);
plot (t,ix); % Plot Imaginary part
xlabel('Time index n ----->');
ylabel('Amplitude ----->');
title('Fig(b): Imaginary part of the given sequence');
Output:
Result:
EXPERIMENT-5
CONVOLUTION BETWEEN SIGNALS/SEQUENCES
Aim:
To find the output with linear convolution operation using MATLAB
software
Software used:
1. Operating system-Windows XP
2. MATLAB R2009b
Theory:
Discrete or Linear convolution:
The Discrete or Linear convolution of x1 n and x 2 n is defined as,
or
x 3 n x k x n k
2 1
k
K is a dummy variable
If the sequence x 1 n has N 1 samples and x 2 n has N 2 samples then the
Program:
%% Linear Convolution of two Signals using conv() function
clc;
clear all;
close all;
subplot(3,1,2);
stem(h);
xlabel('----> n');
ylabel('----> h(n)');
title('Fig(b): Impulse sequence');
subplot(3,1,3);
stem(y);
xlabel('----> n');
ylabel('----> y(n)=x(n)*h(n)');
title('Fig(c): Resultant sequence of Linear convolution');
Output:
Enter the input sequence x(n) like [a c f - - -]= [-1 -2 -3 -4]
Enter the Impulse sequence h(n) like [a c f - -]= [1 2 3 4]
Result:
EXPERIMENT-6
AUTO CORRELATION AND CROSS CORRELATION BETWEEN SIGNALS
AND SEQUENCES
Aim:
To verify the auto correlation and cross correlation function
Software used:
1. Operating system-Windows XP
2. MATLAB 7.0.1v
Theory:
Correlation is a measure of similarity between two continuous or discrete
time signals. Mathematically, the correlation operation resembles that of
convolution to a very good extent. As in the case of convolution, a
mathematical operation is performed on two signals in correlation also to
form a third signal. However, the purpose for which convolution and
correlation are used is completely different. While convolution is used to
obtain the response of an LTI system to an arbitrary input signal, the main
objective of correlation is to measure the degree to which the two signals are
similar. Correlation is of two types, cross correlation, and auto correlation
which are defined as follows:
rxy k xn yn - k
n
yn and „k‟ is the variable used for time shift. The correlation of two different
sequences is called cross correlation and the correlation of a sequence with
rxx k xn xn - k
n
rxy k xn k yn
n
Program:
(i). Auto Correlation of a signal
clc;clear all;
close all;
t = 0:0.01:2; % Declaration of the time interval.
x= cos(2*pi*t); % Generate the cosinusoidal signal
y= xcorr(x); % Generate the ACF of cosine signal
subplot(2,1,1);
plot(x); % Plot the cosinusoidal signal
xlabel('----> Samples');
ylabel('----> Amplitude');
title('Fig(a): Input Signal');
subplot(2,1,2);
plot(y); % Plot the generated ACF signal
xlabel('----> Samples');
ylabel('----> Amplitude');
title('Fig(b): Output Signal (Auto correlated signal)');
Output:
Program:
subplot(3,1,1);
stem(x);
xlabel('n');
ylabel('x(n)');
subplot(3,1,2);
stem(h);
xlabel('n');
ylabel('h(n)');
y=xcorr(x,h);
disp(y);
subplot(3,1,3);
BASIC SIMULATION LAB 62
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS (GNITC)
stem(y);
xlabel('n');
ylabel('y(n)');
Output:
Enter first sequence [1 2 3]
Result:
Viva Questions:
1. What is Correlation?
2. What is the importance of Correlation?
3. What is the difference between Correlation and Convolution?
4. Define ACF and CCF?
EXPERIMENT-7
VERIFICATION OF LINEARITY AND TIME INVARIANCE PROPERTIES OF
A GIVEN CONTINUOUS/DISCRETE SYSTEM
Here a1 and a 2 are arbitrary constants. This condition states that the
response of the linear combination of the inputs x1 (t) and x 2 (t) with arbitrary
In mathematically,
For the system to be linear if,
If the system does not satisfy the above condition, it is called Non-linear
system.
Program:
clc;
clear all;
close all;
x1 = input (' type the samples of x1 ');
x2 = input (' type the samples of x2 ');
if (length(x1) ~= length(x2))
disp(' ERROR : Lengths of x1 & x2 are different ')
return;
end;
h = input (' type the samples of h ');
N = length(x1) + length(h) -1;
disp('length of the output signal will be ');
disp(N);
a1 = input (' The scale factor a1 is ');
a2 = input (' The scale factor a2 is ');
x = a1 * x1 + a2 * x2;
yo1 = conv(x,h);
y1 = conv(x1,h);
y1s = a1 * y1;
y2 = conv(x2,h);
y2s = a2 * y2;
yo2 = y1s + y2s;
disp ('Input signal x1 is '); disp(x1);
disp ('Input signal x2 is '); disp(x2);
disp ('Output Sequence yo1 is ');
disp(yo1);
disp ('Output Sequence yo2 is ');
disp(yo2);
if ( yo1 == yo2 )
disp(' yo1 = yo2. Hence the LTI system is LINEAR ')
end;
Output:
Result:
Program:
x = input( ' Type the samples of signal x(n) ' );
h = input( ' Type the samples of signal h(n) ' );
y = conv(x,h);
disp( ' Enter a POSITIVE number for delay ' );
d = input( ' Desired delay of the signal is ' );
xd = [zeros(1,d), x];
nxd = 0 : length(xd)-1;
yd = conv(xd,h);
nyd = 0:length(yd)-1;
xp = [x , zeros(1,d)];
figure
subplot(2,1,1);
stem(nxd,xp); grid;
xlabel( ' Time Index n ' );
ylabel( ' x(n) ' );
title( ' Original Input Signal x(n) ' );
subplot(2,1,2);
stem(nxd,xd);
grid;
xlabel( ' Time Index n ' );
ylabel( ' xd(n) ' );
title( ' Delayed Input Signal xd(n) ' );
yp = [y zeros(1,d)];
figure
subplot(2,1,1); stem(nyd,yp); grid;
xlabel( ' Time Index n ' );ylabel( ' y(n) ' );
title( ' Original Output Signal y(n) ' );
subplot(2,1,2);
stem(nyd,yd);
grid;
xlabel( ' Time Index n ' );
ylabel( ' yd(n) ' );
title( ' Delayed Output Signal yd(n) ' );
Output:
Result:
***
EXPERIMENT-8
COMPUTATION OF UNIT SAMPLE, UNIT STEP AND SINUSOIDAL
RESPONSES OF THE GIVEN LTI S SYSTEM
Aim:
To find the impulse response of an LTI system
Software used:
1. Operating system-Windows XP
2. MATLAB R2009b
Program:
num = input ('type the numerator vector ');
den = input ('type the denominator vector ');
N = input ('type the desired length of the output sequence N ');
n = 0 : N-1;
imp = [ 1 zeros(1, N-1) ];
h = filter ( num, den, imp );
disp('The impulse response of LTI system is'); disp(h);
stem(n,h)
xlabel ('time index n');
ylabel ('h(n)');
title ('Impulse Response of LTI system');
Output:
Result:
Program:
num = input ('type the numerator vector ');
den = input ('type the denominator vector ');
N = input ('type the desired length of the output sequence N ');
n = 0 : 1 : N-1;
u = ones (1, N);
s = filter ( num, den, u );
disp('The step response of LTI system is'); disp(s);
stem(n,s)
xlabel ('time index n');
ylabel ('s(n)');
title ('Step Response of LTI system');
Output
Result:
***
EXPERIMENT-9
GIBBS PHENOMENON
Software used:
1. Operating system-Windows XP
2. MATLAB R2009b
Theory:
The decomposition of non-periodic or aperiodic signals can also be done
using Fourier transform. When we decompose a signal in to a sum of
sinusoidal components using these powerful mathematical tools called
Fourier series or Fourier Transforms, we are basically resolving the signal
into its frequency components. This process is known as frequency analysis
or spectral analysis of signals.
Every periodic signal has a frequency spectrum consisting of harmonics
with different amplitudes. A harmonic is a signal whose frequency is an
integral multiple of the frequency of some reference signal. The first
harmonic is called the fundamental frequency.
When we add up all the corresponding sinusoidal harmonic components,
it is common sense that we should get back our original periodic signal.
This reconstruction process, which is just the reverse of frequency analysis,
is called Fourier synthesis.
In one such experiment, the American physicist JW Gibbs observed a
peculiar phenomenon like ripples or oscillatory behavior near the jump or
discontinuity of a square wave is known as Gibbs Phenomenon.
Program:
clc;clear all;close all;
t=0:.001:1;
% plot the original square wave with a blue line and thickness of 2 units
plot(t,f,'b','linewidth',2);
hold;
for n=1:2:N
end;
plot(t,sq);
grid();
xlabel('t');
ylabel('ssq(t)');
Output:
EXPERIMENT 10
FOURIER TRANSFORM AND IT’S FREQUENCY SPECTRUM
Aim:
To find the Fourier transform and its magnitude and phase spectrum of
the following signal x(n) = 0.8*Cos(2*pi*f*n), Assume f=150Hz and
n=0:1023 samples
Software used:
1. Operating System-Windows XP
2. MATLAB R2009b
Theory:
The Fourier representation of periodic signals has been extended to non-
periodic signals by letting the fundamental period T tend to infinity, and this
Fourier method of representing non-periodic signals as a function of
frequency is called Fourier Transform. This Fourier representation of signals is
also known as frequency domain representation. In general the Fourier series
representation can be obtained only for periodic signal, but the Fourier
transform technique can be applied to both periodic and non-periodic signals
to obtain the frequency domain representation of the signals.
Ff t F f t e jt dt
-
Program:
clc;clear all;close all;
fs=2000;
subplot(2,1,1);
plot(w,Xmag);
grid;
xlabel('frquency index w -- >');
ylabel('Magnitude -- >');
title('Fig (a): Magnitude of Fourier transform');
subplot(2,1,2);
plot(w,Xphase);
grid;
xlabel('frquency index w -- >');
ylabel('Phase -- >');
title('Fig (b): Phase of Fourier transform');
Output:
Viva Questions:
***
EXPERIMENT-11
WAVEFORM SYNTHESIS USING LAPLACE TRANSFORM
Aim:
To find the Laplace transform of a standard causal signals.
Software used:
1. Operating system-Windows XP
2. MATLAB R2009b
Theory:
The Laplace transform is important mathematical tool which is used for the
analysis of signals and systems. In some cases, Laplace transform can be
used where Fourier transform cannot be used. The Laplace transforms can
be used to analyze continuous time problems involving signals that are not
absolutely integrable, such as the impulse response of unstable systems.
Program:
clc;clear all;close all;
syms t w s;
a=2;
ft3=sinh (w*t);
ft4=cosh (w*t);
ft5=exp (a*t);
ft6=exp (-a*t);
ft7= (exp (a*t))*sin (w*t);
ft8= (exp (-a*t))*cos (w*t);
Output:
Output:
Result:
Viva Questions:
1. What is Waveform Synthesis?
2. What is the difference between Analysis and Synthesis?
3. Find the Inverse Laplace Transform of
a) 1/(s+2) b)1/s3
c) (s2 +2s +9)/(s(s2 +9)) d) 18/(s2(s2 + 9))
4. Find the Laplace Transform of
a) x(t) = (1 – e-2t)*U(t) b) x(t) = U(t) – U(t – 2)
c) x(t) = 10cos(t) – 20Sin(20t) d) x(t) = a2tU(t)
***
EXPERIMENT 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 locating the zeros and poles and plotting the pole-zero maps in s-plane
N S S 2 3S 2
and z-plane for the following transfer function XS
DS S 2 1
[same TF for X(Z)] using MATLAB software
Software used:
1. Operating system-Windows XP
2. MATLAB R2009b
Theory:
In Laplace transforms:
N S
Any function in S-domain XS
DS
In Z-transforms:
N Z
Any function in S-domain XZ
DZ
Where N (Z) = Numerator polynomial, and D (Z) = Denominator polynomial
The roots of the equation, N (Z) = 0 correspond to the „zeros‟ of X (Z)
The roots of the equation, D (Z) = 0 correspond to the „poles‟ of X (Z)
Program:
%% Clearing section
clc;clear all;
close all;
subplot(2,1,1);
subplot(2,1,2);
Output:
Result:
Aim:
Find the following:
i.Z-transform of the standard signals
ii.Inverse Z- transform of the given signals
iii.Residues and poles of the Z-domain signal
iv.Impulse response of discrete time system
Software used:
1. Operating system-Windows XP
2. MATLAB R2009b
Program:
x=n;
disp('(a). z-transform of "n" is :');
disp(ztrans(x));
x=a^n;
disp('(b). z-transform of "a^n" is :');
disp(ztrans(x));
x=n*(a^n);
BASIC SIMULATION LAB 83
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS (GNITC)
x=exp(-a*n*T);
disp('(d). z-transform of "exp(-a*n*T)" is :');
disp(ztrans(x));
Output:
Result:
Program:
Xz=1/(1-1.5*(z^(-1))+0.5*(z^(-2)));
disp('Inverse z-transform of');
disp(Xz);disp('is :');
Xz=iztrans(Xz,z,n);
xn=simplify(Xz);
disp(xn);
Output:
Result:
Program:
clc;
clear all;
H=tf('z');
Ts=0.1;
nc=input('Enter numerator coefficients like [1 2-4 5] :');
dc=input('Enter denominator coefficients like [0 4 5] :');
Output:
Result:
clc;
clear all;
close all;
syms z n;
N=15;
nc=input('Enter numerator coefficients of above funtion H(z) ::');
dc=input('Enter denominator coefficients of above funtion H(z) ::');
stem(n,H);
grid;
xlabel('--> n');
ylabel('---> h(n)');
title('Fig (a): Impulse response h(n)')
Output:
Result:
Viva Questions:
1. What is the need of z-transform?
2. Define Inverse z-transform?
3. Define impulse response?
4. Define poles, zeros and residues?
***
EXPERIMENT-13
GENERATION OF GAUSSIAN NOISE, COMPUTATION OF ITS MEAN, MEAN
SQUARE VALUE (MSV), AND ITS SKEW, KURTOSIS, AND PSD,
HISTOGRAM
Aim:
To generate the Gaussian noise and compute the Mean, MSV, Variance,
and its Skew, Kurtosis, PSD, Histogram using MATLAB software.
Software used:
1. Operating system-Windows XP
2. MATLAB R2009b
Theory:
Gaussian probability or Normal distribution:
A random variable X is called Gaussian, if its density function has the form
x m 2
2
f x x
1
.e 2 x
2 x2
Mean: Mean is the average or mean value. For vectors, mean (R1) is the
mean value of the elements in random signal R1. Expectation is the name
given to the process of averaging when a random variable is involved. It can
denoted as X or E X
In Discrete random variable case:
n
EX xi P x i
i 1
EX xf x dx
x
Mean Square Value: The second moment about the origin of the random
variable X is known as Mean Square Value (MSV) of X.
E X2
2
x fx xdx
expressed as:
E X m x m P x
n
2 2
i i
i 1
i.e.,
Var(X) = E X 2 EX
2
i.e.,
E X m 2 is referred to as Coefficient of Skewness.
x3
Kurtosis: kurtosis (R1) returns the sample kurtosis of the values in R1. For
a vector input, K is the fourth central moment of X, divided by fourth power
of its standard deviation.
PSD: PSD Power Spectral Density estimate. PSD has been replaced by
SPECTRUM objects.
Pwelch: pwelch is the Power Spectral Density estimate via Welch's method.
Hist:
Program:
clc;
clear all;
close all;
subplot(2,2,1);
plot(R1);
xlabel('Sample Number');
ylabel('Amplitude');
title('Fig (a): Normal [Gaussian] Distributed Random Signal');
subplot(2,2,2);
hist(R1); % bins the elements of R1 into equally spaced container
xlabel('Sample Number');
ylabel('Total');
title('Fig (b): Histogram [Pdf] of a normal Random Signal');
subplot(2,2,[3,4]);
plot(x);
xlabel('Sample Number');
ylabel('Amplitude');
title('Fig (c): PSD of a Normal Random Signal');
Output:
Result:
Viva Questions:
1. Define Gaussian Noise?
2. Define Mean, Variance and Skew?
3. Define kurtosis and PSD?
4. Define CDF and PDF?
5. What is the difference between CDF and PDF?
***
EXPERIMENT-14
VERIFICATION OF SAMPLING THEOREM
Aim:
To verify the sampling theorem using MATLAB software.
Software used:
1. Operating system-Windows XP
2. MATLAB R2009b
Theory:
Sampling Theorem:
signal.
Sampling is performed by taking samples of continuous time signal at definite
intervals of time. Usually, the time interval between two successive samples will
be same and such type of sampling is called periodic or uniform sampling.
i.e, f s 2 f m
n
x n = xa t | t nTs = x a nTs = xa ; for n in the range n
fs
Program:
t=-5:.01:5;
T=3; % Assighn Time period
fm=1/T; % Estimate frequency(fm)
subplot(2,1,1);
plot(t,x); % Plot the generated Co-Sine wave
xlabel('--> time');
ylabel('x(t)');
title('Fig(a): Continuous time signal');
grid;
n1=-5:ts1:5;
x1=cos(2*pi*fm*n1);
subplot(2,1,2);
stem(n1,x1,'p');
grid;
xlabel('--> time');
ylabel('x1(n)');
title('Fig(b): discrete time signal with fs<2fm');
x2=cos(2*pi*fm*n2);
subplot(2,1,1);
stem(n2,x2,'m');
xlabel('--> time');ylabel('x2(n)');
title('Fig(c): discrete time signal with fs=2fm');
legend('fs=2fm');
grid;
n3=-5:ts3:5;
x3=cos(2*pi*fm*n3);
subplot(2,1,2);
stem(n3,x3,'.');
xlabel('--> time');
ylabel('x3(n)');
title('Fig(d): discrete time signal with fs>2fm');
legend('fs>2fm');
grid;
Output:
Result:
Viva Questions:
***
EXPERIMENT 15
REMOVAL OF NOISE BY AUTO CORRELATION / CROSS CORRELATION
Aim:
Removal of noise by autocorrelation / cross correlation
Software used:
1. Operating system-Windows XP
2. MATLAB R2009b
Theory:
The cross correlation between two discrete time periodic signals x n and
yn is defined as,
1 N 1
R xy k xn yn - k
N n 0
/2
st nt st nt dt
1
Lim
/ 2
R sn R ns 0
Then R ff R ss R nn
Program:
% clearing section
clc;clear all;close all;
subplot(3,1,1)
plot(s);
xlabel('----> Time (t)');
ylabel('----> Amplitude');
title('Fig (a): Sine signal');
subplot(3,1,2)
plot(f);
xlabel('----> Time (t)');
ylabel('----> Amplitude');
title('Fig (b): Receieved signal f(t)=s(t)+n(t)');
as=xcorr(s,s);
subplot(3,1,3)
plot(as);
xlabel('----> Time (t)');
ylabel('----> Amplitude');
title('Fig (c): Autio Correlation of s(t)');
figure;
an=xcorr(n,n);
subplot(3,1,1)
plot(an);
xlabel('----> Time (t)');
ylabel('----> Amplitude');
title('Fig (d): Autio Correlation of n(t)');
af=xcorr(f,f);
subplot(3,1,2)
plot(af);
xlabel('----> Time (t)');
ylabel('----> Amplitude');
hh=as+an;
subplot(3,1,3)
plot(af);
xlabel('----> Time (t)');
ylabel('----> Amplitude');
title('Fig (f): Addition of ACF of s(t)and ACF of n(t))');
Output:
Result:
Viva Questions:
***
EXPERIMENT 16
EXTRACTION OF PERIODIC SIGNAL MASKED BY NOISE USING
CORRELATION
Aim:
To extract the periodic signal masked by noise using correlation
Software used:
1. Operating system-Windows XP
2. MATLAB R2009b
Program:
clc; clear all;
M = 256;
n = 0 : M-1;
x = cos(16*pi*n/M) + sin(32*pi*n/M);
snr = input( ' Type the desired SNR ' );
px = var(x)
w = sqrt(12) * (rand( 1 , M ) - 0.5);
an = sqrt(px * (10 ^ ( (-1 * snr) / 10) ))
w = w .* an;
pn = var(w)
SNRdb = 10 * log10(px / pn)
y = x + w;
N = M / 8;
L = floor( M / N );
d = zeros( 1 , M );
for i = 1 : M
if rem(i-1,N) == 0
d(i) = 1;
end;
end;
Result:
***
EXPERIMENT 17
VERIFICATION OF WIENER-KHINCHINE RELATION
Aim:
To verify the wiener-khinchine relation
Software used:
1. Operating system-Windows XP
2. MATLAB R2009b
Theory:
The Wiener-khinchine (also known as the Wiener-khintchine theorem
and sometimes as the wiener-khinchin-Einstein theorem) states that the
power spectral density of a wide-sense-stationary random process is the
Fourier transform of the corresponding autocorrelation function. The
theorem is useful for analyzing linear time-invariant systems, LTI
systems, when the inputs and outputs are not square integrable, so
their Fourier transforms do not exist. Mathematically it is expressed as:
Continuous case:
S xx f rxx e j 2f d
Discrete case:
S xx f rxx k e j 2kf
k
and where is the power spectral density of the function with discrete
values.
Program:
clc;
clear all;
close all;
subplot(3,2,1);
plot(x); % plot the sine wave
title('Sine Wave')
subplot(3,2,3);
plot(abs(v)); % Magnitude plot the FFT of ACF of the sine wave
title('Magnitude plot the FFT of ACF of the sine wave')
fw=fft(x);
subplot(3,2,4);
plot(fw);
title('FFT of Sine Wave')
subplot(3,2,5);
plot(fw2);
title('Energy spectral density of Sine Wave')
Output:
Result:
***
EXPERIMENT 18
CHECKING A RANDOM PROCESS FOR STATIONARY IN WIDE SENSE
Aim:
Software used:
1. Operating system-Windows XP
2. MATLAB R2009b
Theory:
f x x1, x2 ,... xN ; t1, t2 ,....t N f y y1, y2 ,... y N ; t11, t12 ,....t1N
Wide sense stationary random processes(WSS RP):
If the statistical properties of a random process, such as the mean, standard
deviation, variance, etc., are invariant to the translation of the time axis ,
such a process is called stationary or strict sense stationary (SSS) random
process. Since SSS condition almost never satisfied in practice, a somewhat
weaker type of stationary called as wide sense stationary (WSS) process is
commonly employed in most of the signal processing applications.
Program:
clc;
clear all;
close all;
syms x ;
mean_value = int(z,Min,Max)
y = subs(z,x,x+5);
Auto_correlation = int(z*y,Min,Max)
Output:
Result:
Viva Questions:
***
ADDITIONAL PROGRAMES
EXP.NO: 1
GENERATION OF DICRETE TIME SIGNALS
Software used:
1. Operating system-Windows XP
2. MATLAB R2009b
Program:
%Impluse
clc;clear all;close all;
n=-10:1:10;
impluse=[zeros(1,10),ones(1,1),zeros(1,10)];
subplot(3,3,1);stem(n,impluse);axis([-10 10 0 1.2]);
xlabel('discrete time n');ylabel('amplitude');
title('unit impluse sequence');
%Unit step
n=-10:1:10;
step=[zeros(1,10),ones(1,11)];
subplot(3,3,2);stem(n,step);
xlabel('discerte time n');ylabel('amplitude');title('unit step sequence');
%Ramp
n=0:1:10
ramp=n;
subplot(3,3,3);stem(n,ramp);
xlabel('discrete time');ylabel('amplitude');
title('ramp signal');
Output:
EXP.NO: 2
RAISED COSINE FILTER
Software used:
1. Operating system-Windows XP
2. MATLAB R2009b
Program:
clc;
clear all;
t = linspace(-30,30,1000);
b= 0.2;
T=1;
h1 = (sin(pi*t/T))./(pi*t/T);
h2 = (cos(pi*b*t/T))./(1-(2*b*t/T).^2);
h = h1.*h2;
figure(1);
plot(t,h);
Output:
Result:
Viva-voce:
1. Define the raised cosine filter?
2. State the purpose for which the raised cosine filters are normally used?
3. What is inter symbol interference?
4. What do you understand by pulse shaping?
5. Draw the frequency responses plot for
(a) high pass filter, (b) low pass filter,
(c)band pass filter, (d) band reject filter?
6.What do you understand by the „bandwidth‟ of filter?
EXP.NO: 3
TO FIND DFT OF GIVEN DISCRETE TIME SIGNAL
Software used:
1. Operating system-Windows XP
2. MATLAB R20009b
Theory:
The discrete Fourier Transform of sequence is Periodic and we are
interested in frequency range 0 to 2π there are infinitely many ω in this
range. If we use a digital computer to compute N equally spaced points over
the interval 0≤ ω<2π then the N points should be located at
ωk = (2π/N)k; k=0,1,2……,N-1;
These N equally space frequency samples of the DTFT are known as DFT
denoted by X(k) is
X(k) = X(ejω)|ω k = (2π/N)k; 0≤k≤N-1.
The formulas for DFT are
DFT 0 ≤ k ≤ N-1.
%DFT function
function X=dft( x, N);
L=length(x);
if(N<L)
error('N must be >=L')
end
x1=[x zeros(1,N-L)];
for k=0:1:N-1;
for n=0:1:N-1;
p=exp(-i*2*pi*n*k/N);
x2(k+1,n+1)=p;
end
end
X=x1*x2;
%to find DFT of given sequence
clc
clear all
close all
x=ones(1,4);
N1=8;
Y1=dft(x,N1);
k=0:1:N1-1;
subplot(2,2,1);
stem(k,abs(Y1));
xlabel('k');
ylabel('|Y1(k)|');
title('')
subplot(2,2,3);
stem(k,angle(Y1));
xlabel('k');
ylabel('arg(Y1(k))');
title('')
N2=31;
Y2=dft(x,N2);
k=0:1:N2-1;
subplot(2,2,2);
stem(k,abs(Y2));
xlabel('k');
ylabel('|Y2(k)|');
title('')
subplot(2,2,4);
stem(k,angle(Y2));
xlabel('k');
ylabel('arg(Y2(k))');
title('')
Output:
Result: