Download - bs lab.doc
-
7/29/2019 bs lab.doc
1/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
CODE OF CONDUCT FOR THE STUDENTS
All students must observe the Dress Code while in the laboratory.
Sandals or open-toed shoes are NOT allowed.
Login in the register.
All bags must be left at the indicated place.
The lab timetable must be strictly followed.
Be PUNCTUAL for your laboratory session.
Program must be executed within the given time.
Noise must be kept to a minimum.
Workspace must be kept clean and tidy at all time.
Handle the systems and interfacing kits with care.
All students are liable for any damage to the accessories due to their own
negligence.
All interfacing kits connecting cables must be RETURNED if you taken from
the lab supervisor.
Students are strictly PROHIBITED from taking out any items from the
laboratory.
Students are NOT allowed to work alone in the laboratory without the Lab
Supervisor
USB Ports have been disabled if you want to use USB drive consult lab
supervisor.
Report immediately to the Lab Supervisor if any malfunction of the
accessories, is there.
Before leaving the lab
Place the chairs properly.
Turn off the system properly
Turn off the monitor.
Please check the laboratory notice board regularly for updates.
Logout the register.
1
-
7/29/2019 bs lab.doc
2/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
LABORATORY INSTRUCTIONS
You should be punctual for your laboratory session and should not leave the lab
without the permission of the teacher.
Each student is expected to have his/her own lab book where they will take notes on
the experiments as they are completed. The lab books will be checked at the end of each labsession. Lab notes are a primary source from which you will write your lab reports.
Organization of the Laboratory
It is important that the programs are done according to the timetable and completed
within the scheduled time.
You should complete the pre-lab work in advance and utilize the laboratory time for
verification only.
The aim of these exercises is to develop your ability to understand, analyze and test
them in the laboratory.A member of staff and a Lab assistant will be available during scheduled laboratory
sessions to provide assistance.
Always attempt program first without seeking help.
When you get into difficulty; ask for assistance.
Assessment
The laboratory work of a student will be evaluated continuously during the semester
for 25 marks. Of the 25 marks, 15 marks will be awarded for day-to-day work. For each
program marks are awarded under three heads:
Observation & viva 5marks, &
Record of the Experiment 5marks
Internal lab test(s) conducted during the semester carries 10 marks.
End semester lab examination, conducted as per the JNTU regulations, carries 50 marks.
At the end of each laboratory session you must obtain the signature of the teacher along with
the marks for the session out of 10 on the lab notebook.
Lab Reports
Note that, although students are encouraged to collaborate during lab, each must individually
prepare a report and submit.
They must be organized, neat and legible.
Your report should be complete, thorough, understandable and literate.
You should include a well-drawn and labeled engineering schematic for each circuit
investigated
Your reports should follow theprescribed format, to give your report structure and to make
sure that you address all of the important points.
Graphics requiring- drawn straight lines should be done with a straight edge. Well drawn
free-hand sketches are permissible for schematics.
2
http://www.soe.ucsc.edu/classes/ee171/Spring05/Lab_reportFormat.htmlhttp://www.soe.ucsc.edu/classes/ee171/Spring05/Lab_reportFormat.htmlhttp://www.soe.ucsc.edu/classes/ee171/Spring05/Lab_reportFormat.html -
7/29/2019 bs lab.doc
3/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Space must be provided in the flow of your discussion for any tables or figures. Do not
collect figures and drawings in a single appendix at the end of the report.
Reports should be submitted within one week after completing a scheduled lab session.
Presentation
Experimental facts should always be given in the past tense.
Discussions or remarks about the presentation of data should mainly be in the present tense.
Discussion of results can be in both the present and past tenses, shifting back and forth from
experimental facts to the presentation.
Any specific conclusions or deductions should be expressed in the past tense.
Report Format:
Lab write ups should consist of the following sections:
Aim:Equipments:
Circuit Diagram:
Theory:
Procedure:
Expected Waveform:
Observation and Calculations:
Results:
Conclusions:
.
Note: Diagrams if any must be drawn neatly on left hand side.
3
-
7/29/2019 bs lab.doc
4/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
LIST OF EXPERIMENTS
1. Basic Operations on Matrices.
2. Generations of Various Signals and sequences (periodic and Aperiodic), such as
unit impulses, unit step, square, saw tooth, triangular, sinusoidal, ramp, sinc.
3. Operation 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 between Signals and Sequences
6. Auto correlation and cross correlation between signals and sequences.
7. Verification of linearity and time invariance properties of a given
continuous/discrete system.
8. Computation of unit samples, unit step and sinusoidal response of the given LTI
system and verifying its physical realiazability and stability properties.
9. Gibbs phenomenon
10. Finding the Fourier Transform of a given signal and plotting its magnitude and
phase spectrum.
11. Wave form synthesis using Laplace Transforms.
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 Gauss ion 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 auto correlation/cross correlation.
16. Extraction of periodic signal masked by noise using correlation.
17. Verification of wiener Khinchine relations.
18. Checking a random process for stationary in wide sense
4
-
7/29/2019 bs lab.doc
5/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
TABLE OF CONTENTS
S.NO UNIT
NO
TOPIC WEEK PAGE
NO1 I Basic Operations on Matrices.
2 I Generations of Various Signals and sequences
(periodic and Aperiodic), such as unit impulses,
unit step, square, saw tooth, triangular,sinusoidal,
ramp, sinc.
3 II Operation on Signals and sequences such as
Addition, Multiplication, Scaling,Shifting,Folding,
Computation of energy and average power
4 II Finding the even and odd parts of signal/sequence
and real and imaginary parts of signal.
5 II Gibbs phenomenon
6 III Convolution between Signals and Sequences
7 III Finding the Fourier Transform of a given signal
and plotting its magnitude and phase spectrum.
8 IV Verification of linearity and time invariance
properties of a given continuous/discrete system.
9 IV Computation of unit samples, unit step and
sinusoidal response of the given LTI system and
verifying its physical realiazability and stability
properties.
10 IV Verification of wiener Khinchine relations
11 V Auto correlation and cross correlation between
signals and sequences.12 V Generation of Gauss ion noise (Real and
Complex), computation of its mean, M.S. value
and its Skew, kurtosis, and PSD, probability
distribution function
13 V Removal of noise by auto correlation/cross
5
-
7/29/2019 bs lab.doc
6/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
correlation.
14 V Extraction of periodic signal masked by noise
using correlation.
15 V Checking a random process for stationary in
wide sense
16 VI Sampling theorem verification
17 VII Wave form synthesis using Laplace Transforms
18 VIII Locating the zeros and poles and plotting the
pole-zero maps in S-plane and Z-plane for the
given transfer function.
MATLAB Programming execution steps:-
Step-1
6
-
7/29/2019 bs lab.doc
7/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Step-2
Step-3
7
-
7/29/2019 bs lab.doc
8/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Step-4
Step-5
8
-
7/29/2019 bs lab.doc
9/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Step-6
9
-
7/29/2019 bs lab.doc
10/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Step-7
10
-
7/29/2019 bs lab.doc
11/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Step-8
Experiment: 1
To perform basic operations on matrices
Aim:-: Basic Operations on Matrices (Addition, Subtraction, Multiplication, Determinant, Trace,
Inverse, Rank etc.,)
Pre requisite:-
1. Study all the basic operations on Matrices
11
-
7/29/2019 bs lab.doc
12/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Apparatus Required:-
1. MATLAB 7.1
2. Windows XP SP2
Algorithm:-
1. Basic Program for Addition, Subtraction and Multiplication of two matrices.
1. Clear the command window
2. Clear all the global variables
3. Delete all existed figures in the window
4. Give the variable name for first matrix.
5. Give the variable name for second matrix.
6. Write the function to find size of matrices
7. Write the functions to find the addition ,subtraction, ,multiplication of two matrices
Program:-clc;clear all;close all;A = input('Enter the Matrix A ::');B = input('Enter the Matrix B ::');%%%% Find the size of matricesdisp('The sise of Matrix A is .... :: ');disp(size(A));disp('The sise of Matrix B is .... :: ');disp(size(B));%%%% Addition of two matricesdisp('Addition of A and B Matrices is .....:: ');disp(A + B);%%%%% Subtration of two matricesdisp('Subtraction of A and B Matrices is .....:: ');disp(A - B);%%%%% Multiplication (ELEMENT BY ELEMENT) of two matricesdisp('Multiplication of A and B Matrices is .....:: ');disp(A .* B);
OUTPUT
Enter the Matrix A ::[1 2 3 4 5 6 7 ]
Enter the Matrix B ::[1 2 3 4 5 6 7 ]
The sise of Matrix A is .... ::
1 7
The sise of Matrix B is .... ::
1 7
12
-
7/29/2019 bs lab.doc
13/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Addition of A and B Matrices is .....::
2 4 6 8 10 12 14
Subtraction of A and B Matrices is .....::
0 0 0 0 0 0 0
Multiplication of A and B Matrices is .....::
1 4 9 16 25 36 49
Algorithm:-
2. Basic Program for Determinant, Trace, Inverse, Rank of a Square Matrix.
1. Clear the command window
2. Clear all the global variables
3. Delete all existed figures in the window
4. Give the variable name for square matrix.5. Write the functions to find the Determinant, Trace, Inverse, Rank of a Square Matrix.
Program:-
clear all;close all;clc;A = input('Enter the Square Matrix A ::');% Finding the Rank of the matrixdisp('Rank of Matrix A is ::');disp(rank(A));
% Find the determinent of the matrixdisp('Determinent of Matrix A is ::'); disp(det(A));
% Find the trace of the matrixdisp('Trace of Matrix A is ::');disp(trace(A));
% Find the Inverse of the matrixdisp('Inverse of Matrix A is ::');disp(inv(A));
OUTPUT
Enter the Square Matrix A ::[1 2 3;3 2 3;1 3 3]
Rank of Matrix A is ::
3
Determinent of Matrix A is ::
6
Trace of Matrix A is ::
13
-
7/29/2019 bs lab.doc
14/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
6
Inverse of Matrix A is ::
-0.5000 0.5000 0.0000
-1.0000 0 1.0000
1.1667 -0.1667 -0.6667
Result:-
Viva Questions:-1. What is MATLAB
2. Expand MATLAB? And importance of MATLAB
3. What is clear all and close all will do?
4. What is disp( ) and input( )
References:-
1. Getting started with MATLAB by Rudra Pratap
2. Signals and systems by .Ramesh Babu
3. Signals and systems by A.Anand Kumar
4. Signals, systems and communications by B.P.Lathi
Experiment: 2Generation of various signals and sequences
Aim:-: Generate various signals and sequences (Periodic and Aperiodic), such as Unit Impulse, Unit
Step, Square, Saw Tooth, Triangular, Sinusoidal, Ramp, Sinc.
Pre requisite:-
1. Study all the Basic Signals and Sequences
2. Study all the Functional Representations of Basic Signals and Sequences
14
-
7/29/2019 bs lab.doc
15/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Apparatus Required:-
1. MATLAB 7.1
Algorithm:-
1. Generate Sinusoidal signal
1. Clear the command window
2. Clear all the global variables
3. Delete all existed figures in the window
4. Give the variable name for number of cycles.
5. Specify the time period of the signal
6. Give the amplitude of the signal with variable
7. Give the function to plot the continuous signal
8. Give the names for x label and y label and title of the figure
9. Give the function to plot the discrete signal
10. Give the names for x label and y label and title of the figure
.
Program:-
clc;
clear all;
close all;
N = input('Enter the number of cycles ...:: ');
t = 0:0.05:N;
x = sin(2*pi*t);
subplot(1,2,1);
plot(t,x);
xlabel('---------> Time');
ylabel('---------> Amplitude');
title('Sinusoidal');
subplot(1,2,2);
stem(t,x);
xlabel('---------> Time');
ylabel('---------> Amplitude');
title('Sinusoidal');
OUTPUT
Enter the number of cycles ...:: 2
15
-
7/29/2019 bs lab.doc
16/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Algorithm:-
2. Generate Unit Impulse function
1. Clear all the global variables
2. Delete all existed figures in the window
3. Clear the command window
4. Give the input variable name for 1x1 matrix consisting of all ones
5. Give the input variable name for 1x2 matrix consisting of all zeros
6. Give the out put variable and write output function interms of inputs
16
-
7/29/2019 bs lab.doc
17/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
7. Give the function to plot the discrete signal of output function.
8. Give the names for x label and y label and title of the figure
Program:-
clear all;close all;clc;
x = ones(1,1);y = zeros(1,2);z = [y, x, y];stem(z);xlabel('---------> Time');ylabel('---------> Amplitude');title('Unit Impulse');
OUTPUT
Algorithm:-
3. Generate Unit Step function
1. Clear all the global variables
2. Delete all existed figures in the window
3. Clear the command window
4. Give the input variable name for matrix consisting of all ones
17
-
7/29/2019 bs lab.doc
18/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
5. Give the function to plot the continuous signal
6. Give the function to plot the discrete signal.
7. Give the names for x label and y label and title of the figure
Program:-
clear all;close all;clc;
x = ones(100);
subplot(2,1,1);plot(x);xlabel('---------> Time');ylabel('---------> Amplitude');title('Step signal');
subplot(2,1,2);stem(x);xlabel('---------> Time');ylabel('---------> Amplitude');title('Step signal');
18
-
7/29/2019 bs lab.doc
19/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
OUTPUT
Algorithm:-
4. Generate Ramp function
1. Clear the command window
2. Clear all the global variables
3. Delete all existed figures in the window
4. Specify the time period of the signal
5. Give the amplitude of the signal with variable (y=t)
6. Give the function to plot the continuous signal
7. Give the names for x label and y label and title of the figure
8. Give the function to plot the discrete signal
9. Give the names for x label and y label and title of the figure
19
-
7/29/2019 bs lab.doc
20/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Program:-
clear all;close all;clc;
t = 0:25;y = t;
subplot(1,2,1);plot(t,y);xlabel('---------> Time');ylabel('---------> Amplitude');title('Ramp function');
subplot(1,2,2);
stem(t,y);xlabel('---------> Time');ylabel('---------> Amplitude');title('Ramp function');
OUTPUT
20
-
7/29/2019 bs lab.doc
21/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Algorithm:-
Generate Sawtooth Waveform
1. Clear the command window
2. Clear all the global variables
3. Delete all existed figures in the window
4. Give the variable name for number of cycles.
5. Specify the time period of the signal
6. Give the amplitude of the signal with variable
7. Give the function to plot the continuous signal
8. Give the names for x label and y label and title of the figure
9. Give the function to plot the discrete signal
10. Give the names for x label and y label and title of the figure
Program:-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('Sawtooth waveform');
subplot(2,1,2);stem(t);xlabel('---------> Time');ylabel('---------> Amplitude');title('Sawtooth waveform');
OUTPUT
Enter the number of cycles ...:: 3
21
-
7/29/2019 bs lab.doc
22/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Algorithm:-Generate Triangular Waveform
1. Clear the command window
2. Clear all the global variables
3. Delete all existed figures in the window
4. Give the variable name for number of cycles.
5. Give the variable name for enter the time period
6. Specify the time period of the signal
7. Give the amplitude of the signal with variable
8. Give the function to plot the continuous signal
9. Give the names for x label and y label and title of the figure
10. Give the function to plot the discrete signal
11. Give the names for x label and y label and title of the figure
Program:-clc;clear all;close all;
N = input('Enter the number of cycles .....:: ');M = input('Enter the period ....:: ');t1 = 0:0.1:M/2;t2 = M/2:-0.1:0;t = [];
22
-
7/29/2019 bs lab.doc
23/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
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
>>
23
-
7/29/2019 bs lab.doc
24/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Algorithm:-
Generate Square waveform
1. Clear all the global variables
2. Delete all existed figures in the window
3. Clear the command window
4. Give the variable name for number of cycles.
5. Give the variable name for enter the time period
6. Give the amplitude of the signal with variable
7. Give the function to plot the continuous signal
8. Give the names for x label and y label and title of the figure
Program:-
clear all;close all;clc;N = input('Enter the number of cycles in a square wave....:: ');
M = input('Enter the period of the square wave ....:: ');y=0:0.001:2;for j=0:M/2:M*N;
x=y;plot(j,x,'r');hold on;
endfor k=0:M:M*N;
x=k+y;m=2;plot(x,m,'r')
hold onendfor k=2:M:M*N;
x=k+y;m=0;plot(x,m,'r');hold on;
endhold offaxis([0 12 -0.5 2.5])xlabel('time---->');ylabel('Amplitude--->');
title('Square wave');
OUTPUTEnter the number of cycles in a square wave....:: 3
Enter the period of the square wave ....:: 4
24
-
7/29/2019 bs lab.doc
25/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Algorithm:-
Generate Sinc function
1. Clear all the global variables
2. Delete all existed figures in the window
3. Clear the command window
4. Specify the time period of the signal
5. Specify the amplitude of the sinc signal
6. Give the function to plot the sinc signal
7. Give the names for x label and y label and title of the figure
Program:-
clear all;close all;clc;
t = -3:0.1:3;x = sin(pi*t)./(pi*t);
subplot(1,2,1); plot(x);xlabel('---------> Time');ylabel('---------> Amplitude');title('Sinc function');axis([0,100,-0.5,1.0]);
subplot(1,2,2); stem(x);xlabel('---------> Time');ylabel('---------> Amplitude');title('Sinc function');axis([0,100,-0.5,1.0]);
25
-
7/29/2019 bs lab.doc
26/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
OUTPUT
Result:-
Viva questions:-
1. What is subplot(), stem(), plot()?
2. What is xlabel(), ylabel(), title()?
3. What do you mean by time scale?
4. What is signal?
5. What is system?
Frequently asked questions:-
1. Classify the signals?
2. What is the difference between continuous and discrete time signals?
3. Explain periodic and aperiodic signals?
4. Explain unit step, ramp, parabolic and impulse signals?
5. Generate the following figures
26
-
7/29/2019 bs lab.doc
27/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
27
-
7/29/2019 bs lab.doc
28/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
References:-
1. Getting started with MATLAB by Rudra Pratap
2.Signals and systems by .Ramesh Babu
3. Signals and systems by A.Anand Kumar
4. Signals, systems and communications by B.P.Lathi
28
-
7/29/2019 bs lab.doc
29/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Experiment:3
Performing operations of signals and sequences
Aim:-Operation on Signals and Sequences such as Addition, Multiplication, Scaling, Shifting, Folding,
Computation of Energy and Average Power.
Pre requisite:-
1. Study the concepts of Scaling, Folding and Shifting of Signals or Sequences
2. Study the concepts of energy and Average Power Calculation of Signals or Sequences
Equipment Required:-
1. MATLAB 7.1
Algorithm:-
Addition and Multiplication of two Sequences
1. Clear all the global variables
2. Delete all existed figures in the window
3. Clear the command window
4. Give the variable name for first input sequence
5. Give the variable name for second input sequence
6. Specify the length of first sequence with variable
7. Specify the length of second sequence with variable
8. Add two input sequences and assign the result with variable
9. Plot the discrete signals for two input sequences and out put sequence.
10. Give the names for x label and y label and title of the figure
11. Multiply two input sequences and assign the result with variable
12. Plot the discrete signal for output sequence.
13. Give the names for x label and y label and title of the figure
Program:-clear all;close all;clc;
x = input(' Enter sequence 1 :: ');y = input(' Enter sequence 2 :: ');M = length(x);N = length(y);subplot(2,2,1);stem(x);xlabel('---->Time ');ylabel('---->Amplitude ');title('Input sequence 1');subplot(2,2,2);stem(y);
xlabel('---->Time ');
29
-
7/29/2019 bs lab.doc
30/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
ylabel('---->Amplitude ');title('Input sequence 2');if M > N
z = x + [y,zeros(1,M-N)];else
z = [x,zeros(1,N-M)] + y;end;subplot(2,2,3);stem(z);xlabel('---->Time ');ylabel('---->Amplitude ');title('Addition of sequences 1 and 2');
if M > Na = x.*[y,zeros(1,M-N)];
elsea = [x,zeros(1,N-M)].*y;
end;subplot(2,2,4);stem(a);xlabel('---->Time ');ylabel('---->Amplitude ');title('Multiplication of sequences 1 and 2');
OUTPUT
Enter sequence 1 :: [1 2 3 4 5 1 2 3 4 5 1 2 3 4 5]Enter sequence 2 :: [5 6 7 8 9 9 8 7 6 5]
30
-
7/29/2019 bs lab.doc
31/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Result:-
Viva questions:-
1. What is Length() function
2. What do you mean by zeros(m,n) and ones(m,n)?
3. What are the basic operations on signals?
4. What is amplitude scaling and time scaling?
5. What is time shifting and time reversal?
Frequently asked questions:-
1.Generate the following signals
a)u(-t+3) b)-2u(t+7) c)-4r(t)2.What is analog and digital signal?
3. Distinguish between deterministic and random signals.
4.Is the sum of two periodic signls always periodic?
5.What is the fundamental period of a discrete time sinusoidal sequence?
References:-
1. Getting started with MATLAB by Rudra Pratap
2. Signals and systems by .Ramesh Babu
31
-
7/29/2019 bs lab.doc
32/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
3. Signals and systems by A.Anand Kumar
4. Signals, systems and communications by B.P.Lathi
Experiment: 4
Finding the even and odd part of signal/sequence
Aim:-: Finding the even and odd parts of signal/sequence and real and imaginary parts of signal.
Pre requisite:-
1. Study all the Basic Signals and Sequences
2. Study all the Functional Representations of Basic Signals and Sequences
Apparatus Required:-
1. MATLAB 7.1
Algorithm:-
Even and Odd part of Signal
1. Clear all the global variables
2. Delete all existed figures in the window
3. Clear the command window
4. Specify the time period
5. Specify the amplitude for f(t) signal
6. Specify the amplitude for f(-t) signal
7. Plot the discrete signal for f(t)
8. Plot the discrete signal for f(-t)
32
-
7/29/2019 bs lab.doc
33/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
9. Give the names for x label and y label and title of the figure
10. Specify the functions for even part and odd part of the original signals
11. Plot the discrete signal for even and odd part of original signal.
12. Give the names for x label and y label and title of the figure
Program:-
clear all;close all;clc;t = 0:10;x = 2*sin(t);y = -(4 * x);subplot(2,2,1);
stem(x);xlabel('Time ----> ');ylabel('Amplitude ---->');title('Original signal f(t)');subplot(2,2,2);stem(y);xlabel('Time ----> ');ylabel('Amplitude ---->');title('Original signal f(-t)');
even =0.5*(x + y);
subplot(2,2,3);stem(even);xlabel('Time ----> ');ylabel('Amplitude ---->');title('Even part');
odd = 0.5*(x - y);subplot(2,2,4);stem(odd);xlabel('Time ----> ');
ylabel('Amplitude ---->');title('Odd part');
OUTPUT
33
-
7/29/2019 bs lab.doc
34/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Algorithm:-
Even and Odd part of Sequence
1. Clear all the global variables2. Delete all existed figures in the window
3. Clear the command window
4. Specify the input variable for enter the sequence
5. Specify the other variable interms of input variable
6. Plot the discrete signal for f(t)
7. Plot the discrete signal for f(-t)
8. Give the names for x label and y label and title of the figure
9. Specify the functions for even part and odd part of the original signals
10. Plot the discrete signal for even and odd part of original signal.
11. Give the names for x label and y label and title of the figure
34
-
7/29/2019 bs lab.doc
35/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
2. Even and Odd part of Sequence
clear all;close all;clc;
x = input('Enter the sequence :: ');y = -x;
subplot(2,2,1);stem(x);xlabel('Time ----> ');ylabel('Amplitude ---->');title('Original signal f(t)');
subplot(2,2,2);stem(y);xlabel('Time ----> ');ylabel('Amplitude ---->');title('Original signal f(-t)');
even =0.5*(x + y);
subplot(2,2,3);stem(even);xlabel('Time ----> ');ylabel('Amplitude ---->');title('Even part');
odd = 0.5*(x - y);
subplot(2,2,4);stem(odd);xlabel('Time ----> ');ylabel('Amplitude ---->');title('Odd part');
OUTPUT
Enter the sequence :: [1 2 3 4 3 2 1]
>> x
x =
1 2 3 4 3 2 1
>> y
y =
-1 -2 -3 -4 -3 -2 -1
35
-
7/29/2019 bs lab.doc
36/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
.
Result:-
Viva questions:-1. What is an even function?
2. What is an odd function?
3. What do you mean by real part and an imaginary part ?
4. Distinguish between even and odd signals?
5. Define causal and non causal signals?
Frequently asked questions:-
1. Can every signal be decomposed into even and odd parts?
2. Distinguish between energy and power signals?
3. How to get even and odd part from the signal?
4. What are the types of representation of the discrete signals?
36
-
7/29/2019 bs lab.doc
37/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
5. Find the even and odd component of x(t)=1+2t+3t2+4t3
References:-
1. Getting started with MATLAB by Rudra Pratap
2. Signals and systems by .Ramesh Babu
3. Signals and systems by A.Anand Kumar
4. Signals, systems and communications by B.P.Lathi
Experiment: 5
Convolution between signals and sequences
Aim:-: Verifying the Convolution between Signals and Sequences
Pre requisite:-
1. Study the details of linear convolution
2. Study the details of circular convolution
Apparatus Required:-
1. MATLAB 7.1
Algorithm:-
Linear Convolution of two Sequences
37
-
7/29/2019 bs lab.doc
38/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
1. Clear all the global variables
2. Delete all existed figures in the window
3. Clear the command window
4. Give the variable name for first input sequence
5. Give the variable name for second input sequence
6. Plot the discrete signals for two input sequences.
7. Specify the functions for convolution between two input sequences.
8. Plot the discrete signal for an output.
Program:-
clear all;close all;clc;x=input('enter the seq1 :: ');
h=input('enter the seq2 :: ');
subplot(3,1,1);stem(x);
subplot(3,1,2);stem(h);o=zeros(1,length(x)+length(h)-1);for m=1:length(x),
for n=1:length(h),y(m,n)=x(m)*h(n);end;
end;for n=1:length(x)+length(h)-1,
for i=1:length(x),for j=1:length(h),
if(i+j==n+1)o(n)=o(n) + y(i,j);
end;end;
end;end;
subplot(3,1,3);
stem(o);
OUTPUT
enter the seq1 :: [1 2 3 4 3 2 1]
enter the seq2 :: [4 3 2 1 2 3 4]
38
-
7/29/2019 bs lab.doc
39/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Algorithm:-
Linear Convolution of two Signals
1. Clear all the global variables
2. Delete all existed figures in the window
3. Clear the command window
4. Specify the time period
5. Specify the amplitude with a variable for first signal
6. Specify the amplitude with a variable for second signal
7. Plot the discrete signals for two input sequences.
8. Specify the functions for convolution between two input signals
9. Plot the discrete signal for an output.
39
-
7/29/2019 bs lab.doc
40/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
clear all;close all;clc;t = 1:10;x = sin(t);h = square(t);subplot(3,1,1);stem(x);
subplot(3,1,2);stem(h);o=zeros(1,length(x)+length(h)-1);
for m=1:length(x),
for n=1:length(h),y(m,n)=x(m)*h(n);end;
end;for n=1:length(x)+length(h)-1,
for i=1:length(x),for j=1:length(h),
if(i+j==n+1)o(n)=o(n) + y(i,j);
end;
end;end;end;
subplot(3,1,3);stem(o);
OUTPUT
>> x
x =
Columns 1 through 7
0.8415 0.9093 0.1411 -0.7568 -0.9589 -0.2794 0.6570
Columns 8 through 10
0.9894 0.4121 -0.5440
>> h
h =
40
-
7/29/2019 bs lab.doc
41/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
1 1 1 -1 -1 -1 1 1 1 -1
>>
Algorithm:-
Linear Convolution of two Signals
1. Clear all the global variables
2. Delete all existed figures in the window
3. Clear the command window
4. Specify the time period
5. Specify the amplitude with a variable for first signal
6. Specify the amplitude with a variable for second signal
7. Plot the discrete signals for two input sequences.
8. Specify the convolution function between two input signals
9. Plot the discrete signal for an output.
41
-
7/29/2019 bs lab.doc
42/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Program:-
clear all;close all;clc;
t = 1:10;x = sin(t);h = square(t);subplot(3,1,1);stem(x);
subplot(3,1,2);stem(h);o = conv(x,h);
subplot(3,1,3);stem(o);
OUTPUT
>> x
x =
Columns 1 through 7
0.8415 0.9093 0.1411 -0.7568 -0.9589 -0.2794 0.6570
Columns 8 through 10
0.9894 0.4121 -0.5440
>> hh =
1 1 1 -1 -1 -1 1 1 1 -1
42
-
7/29/2019 bs lab.doc
43/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Result:-
Viva questions:-1. What is Convolution?
2. What is the importance of convolution?
3. What is the difference between Linear and Circular Convolution?
4. Define the term linearity?
5. What do you mean by periodic or circular convolution?
Frequently asked questions:-
1. What do you mean by regular convolution?
2. Explain the term convolution as applied to a system. illustrate your ans with suitable
examples?
3. What is the convolution of a signal with an impulse?
4. State time convolution theorem?
5. State the shift property of convolution?
References:-
1. Getting started with MATLAB by Rudra Pratap
2. Signals and systems by .Ramesh Babu
3. Signals and systems by A.Anand Kumar
4. Signals, systems and communications by B.P.Lathi
43
-
7/29/2019 bs lab.doc
44/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Experiment: 6
Auto correlation and cross correlation between signals and sequences.
Aim:-: Auto Correlation and Cross Correlation between Signals and Sequences
Pre requisite:-
1. Study in detail about Correlation and how to calculate Correlation of two signals or sequences
Apparatus Required:-
1. MATLAB 7.1
Algorithm:-
Auto Correlation of a Sequence
1. Clear all the global variables
2. Delete all existed figures in the window
3. Clear the command window
4. Give the variable name for first input sequence
5. Specify the output function as correlation of input
6. Plot the discrete signal for input sequence.
7. Plot the discrete signal for an output.
8. Give the names for x label and y label and title of the figure
Program:-
1. Auto Correlation of a Sequence
clear all;close all;clc;
a = input('Enter the sequence ....:: ');res = xcorr(a);subplot(2,1,1);stem(a);xlabel('----> Samples');ylabel('----> Amplitude');title('Input Sequence');subplot(2,1,2);stem(res);
xlabel('----> Samples');
44
-
7/29/2019 bs lab.doc
45/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
ylabel('----> Amplitude');title('Output Sequence');
OUTPUT
Enter the sequence ....:: [1 2 3 4]
Algorithm:-
Auto Correlation of a signal
1. Clear all the global variables
2. Delete all existed figures in the window
3. Clear the command window
4. Specify the time period
5. Specify the input signal function
6. Specify the output function as correlation of input
7. Plot the discrete signal for input signal.
8. Plot the discrete signal for an output.
9. Give the names for x label and y label and title of the figure
45
-
7/29/2019 bs lab.doc
46/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Program:-
clear all;close all;clc;t = 0:0.01:2;a = cos(2 * pi * t);res = xcorr(a);
subplot(2,1,1);plot(a);xlabel('----> Samples');ylabel('----> Amplitude');title('Input Sequence');subplot(2,1,2);plot(res);xlabel('----> Samples');ylabel('----> Amplitude');title('Output Sequence');
OUTPUT
46
-
7/29/2019 bs lab.doc
47/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Algorithm:-
Cross Correlation of two Sequences
1. Clear all the global variables
2. Delete all existed figures in the window
3. Clear the command window
4. Give the variable name for first input sequence
5. Give the variable name for second input sequence
6. Specify the output function as cross correlation of two inputs
7. Plot the discrete signal for input sequence 1.
8. Plot the discrete signal for input sequence 2
9. Plot the discrete signal for an output.
10. Give the names for x label and y label and title of the figure
Program:-
clear all;close all;clc;a = input('Enter the first sequence ....:: ');b = input('Enter the second sequence ....:: ');res = xcorr(a,b);subplot(2,2,1);stem(a);
xlabel('----> Samples');ylabel('----> Amplitude');title('Input Sequence(1)');subplot(2,2,2);stem(b);xlabel('----> Samples');ylabel('----> Amplitude');title('Input Sequence(2)');subplot(2,2,[3,4]);stem(res);xlabel('----> Samples');
ylabel('----> Amplitude');title('Output Sequence');
OUTPUT
Enter the first sequence ....:: [1 2 3 4]
Enter the second sequence ....:: [4 3 2 1]
47
-
7/29/2019 bs lab.doc
48/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Algorithm:-
Cross Correlation of a two Signals
1. Clear all the global variables
2. Delete all existed figures in the window
3. Clear the command window
4. Specify the time period
5. Specify the first input signal function
6. Specify the second input signal function-+-+
7. Specify the output function as cross correlation of input
8. Plot the discrete signal for first input signal9. Plot the discrete signal for second input signal
10. Plot the discrete signal for an output.
11. Give the names for x label and y label and title of the figure
Program:-
clear all;close all;clc;
48
-
7/29/2019 bs lab.doc
49/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
t = 0:0.01:2;a = cos(2 * pi * t);b = sin(2 * pi * t);res = xcorr(a,b);
subplot(2,2,1);plot(a);xlabel('----> Samples');ylabel('----> Amplitude');title('Input signal(1)');subplot(2,2,2);plot(b);xlabel('----> Samples');ylabel('----> Amplitude');title('Input Signal(2)');subplot(2,2,[3,4]);plot(res);xlabel('----> Samples');ylabel('----> Amplitude');title('Output Signal');
OUTPUT
49
-
7/29/2019 bs lab.doc
50/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
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 auto correlation?
5. Define cross correlation?
Frequently asked questions:-
1. Define convolution?
2. What are the advantages of auto correlation &cross correlation and applications?
3. What are incoherent signals?
4. What are properties of cross correlation for energy signals?
5. What are properties of autocorrelation of energy signals?
References:-
1. Getting started with MATLAB by Rudra Pratap
2. Signals and systems by .Ramesh Babu
3. Signals and systems by A.Anand Kumar
4. Signals, systems and communications by B.P.Lathi
50
-
7/29/2019 bs lab.doc
51/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Experiment: 7
Verification of linearity and time invariance properties of a given
continuous/discrete system.
Aim:-: Verification of Linearity and Time Invariance properties of a given Continuous
/ Discrete system.
Pre requisite:-
Study the Concept of Linearity and Time Invariance of a given continuous / discrete system
Apparatus Required:-
1. MATLAB 7.1Algorithm:-
Linearity of a system
1. Clear all the global variables
2. Delete all existed figures in the window
3. Clear the command window
4. Specify the time period
5. Specify the constants a and b
6. Specify the first input signal function
7. Specify the second input signal function
8. Specify the system function
9. Give the functions to verify the linearity of the system
10. Plot the discrete signal for an output of the system.
11. Give the names for x label and y label and title of the figure
Program:-
clear all;close all;clc;
n=0:0.01:2;a= -3; b= 5;x1=cos(2*pi*n);x2=cos(3*pi*n);x=a*x1+b*x2;ic=[0 0];num=[2.2403 2.4908 2.2403];den=[1 -0.4 0.75];
y1=filter(num,den,x1,ic);
51
-
7/29/2019 bs lab.doc
52/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
y2=filter(num,den,x2,ic);y=filter(num,den,x,ic);yt=a*y1+b*y2;d=y-yt;
subplot(3,1,1), stem(n,y);xlabel('---------> Time');ylabel('-> Amplitude');title('y = a*x1 + b*x2');subplot(3,1,2), stem(n,yt);xlabel('---------> Time');ylabel('-> Amplitude');title('yt = a*y1 + b*y2');subplot(3,1,3), stem(n,d);xlabel('---------> Time');ylabel('-> Amplitude');title('difference of y and yt');
OUTPUT
52
-
7/29/2019 bs lab.doc
53/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Algorithm:-
Time Invariance of a system
1. Clear all the global variables
2. Delete all existed figures in the window
3. Clear the command window
4. Specify the time period
5. Specify the constants D
6. Specify the input signal function
7. Specify the system function
8. Give the functions to verify the time invariance of a system
9. Plot the discrete signal for an output of the system.
10. Give the names for x label and y label and title of the figure
Program:-
clear all;close all;clc;n=0:0.05:4;D=10;x=3*cos(2*pi*n)-0.5*cos(4*pi*n);xd=[zeros(1,D) x];
num=[2.2403 2.4908 2.2403];den=[1 -0.4 0.75];ic=[0 0];y=filter(num,den,x,ic)yd=filter(num,den,xd,ic)d=y-yd(1+D:41+D);subplot(3,1,1), stem(y);xlabel('---------> Time');ylabel('-> Amplitude'); title('y ');
subplot(3,1,2), stem(yd);xlabel('---------> Time');ylabel('-> Amplitude'); title('yd');subplot(3,1,3), stem(d);xlabel('---------> Time');ylabel('-> Amplitude');title('difference of y and yd');
53
-
7/29/2019 bs lab.doc
54/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
OUTPUT
Result:-
Viva questions:-1. What is Linearity and give the condition for a system?
2. What is Time Invariance and give the condition for a system?
3. Explain what is meant by the linearity of a system?
4. What are the problems associated with a non linear system?
5. Discuss on whether linearity is an advantage or disadvantage to a system?
Frequently asked questions:-
1. Has nonlinearity is an advantage over linearity with regards to the operation of a system?
2. Check the linearity of the following systems
a. y(n) = [x(n)]2
b. y(n) = exp(x(n))
c. y(t) = 7x(t) + 5
54
-
7/29/2019 bs lab.doc
55/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
3. Check the Time Invariance of the following systems
a. y(n) = a [x(n)]2 + b x(n)
b. y(t) = x(t + 7)
4. Define stable and unstable systems?
5. What is superposition property?
References:-
1. Getting started with MATLAB by Rudra Pratap
2. Signals and systems by .Ramesh Babu
3. Signals and systems by A.Anand Kumar
4. Signals, systems and communications by B.P.Lathi
55
-
7/29/2019 bs lab.doc
56/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Experiment: 8
Computation of unit samples, unit step and sinusoidal response of the
given LTI system
Aim:-
: Computation of unit samples, unit step and sinusoidal response of the given LTI system and
verifying its physical realiazability and stability properties.
Pre requisite:-
1. Study the details of LTI systems
2. Study stability and physical realiazability properties
Apparatus Required:-
1. MATLAB 7.1
Algorithm:-
Linearity of a system
1. Clear all the global variables
2. Delete all existed figures in the window
3. Clear the command window
4. Specify the function (h) for number of samples
5. Specify the impulse function (u)
6. For impulse response convolute between u and h
7. Plot the impulse response of LTI system
8. Give the names for x label and y label and title of the figure
Program:-
clear all;close all;clc;h = (-0.9).^[0:49];
subplot(2,2,1);stem([0:49],h, 'filled');xlabel('Samples');ylabel('Amplitude');title('h = (-0.9).^[0:49]');u = ones(1);subplot(2,2,2);stem(u,'filled');xlabel('Samples');ylabel('Amplitude');title('Impulse');
56
-
7/29/2019 bs lab.doc
57/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
s = conv(u,h);subplot(2,2,[3,4]);stem([0:49],s(1:50));xlabel('Samples');ylabel('Amplitude');title('Response for an impulse');
OUTPUT
Algorithm:-
2. Step Response of an LTI system
1. Clear all the global variables
2. Delete all existed figures in the window
3. Clear the command window
4. Specify the function (h) for number of samples
5. Specify the unit step function (u)
6. For unit step response, convolute between u and h
7. Plot the unit step response of LTI system
8. Give the names for x label and y label and title of the figure
57
-
7/29/2019 bs lab.doc
58/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Program:-
clear all;close all;clc;
h = (-0.9).^[0:49];subplot(2,2,1);stem([0:49],h,'filled');xlabel('Samples');ylabel('Amplitude');title('h = (-0.9).^[0:49]');u = ones(1,50);subplot(2,2,2);stem([1:50],u,'filled');xlabel('Samples');ylabel('Amplitude');title('Step');
s = conv(u,h);subplot(2,2,[3,4]);stem([0:49],s(1:50));xlabel('Samples');ylabel('Amplitude');title('Response for a step');
OUTPUT
58
-
7/29/2019 bs lab.doc
59/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Algorithm:-
Sinusoidal Response of an LTI System
1. Clear all the global variables
2. Delete all existed figures in the window
3. Clear the command window
4. Specify the time period
5. Specify the function (h) for number of samples
6. Specify the function (u) sinusoidal signal
7. For sinusoidal response, convolute between u and h
8. Plot the sinusoidal response of LTI system
9. Give the names for x label and y label and title of the figure
Program:-
clear all;
close all;clc;t = 1:0.04:2;h = (-0.9).^t;subplot(2,2,1);stem(t,h,'filled');xlabel('Samples');ylabel('Amplitude');title('h = (-0.9).^t');u = sin(2*pi*t);subplot(2,2,2);
stem(t,u,'filled');xlabel('Samples');ylabel('Amplitude');title('Sine');s = conv(u,h);subplot(2,2,[3,4]);stem([0:49],s(1:50));xlabel('Samples');ylabel('Amplitude');title('Response for a sine');
59
-
7/29/2019 bs lab.doc
60/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
OUTPUT
Result:-
Viva questions:-1. What is an LTI System?
2. What is the importance of impulse response?
3. Define transfer function of a system?
4. Define causality of a system?
5. Define stable and unstable system?
Frequently asked questions:-
1. Define Stability?
2. Specify whether the system is stable or not
a. x(t) = 2.5 *exp(t) U(t)
60
-
7/29/2019 bs lab.doc
61/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
b. x(n) = 0.5*(-0.5)^n U(n)
3. Define invertibility?
4. What are the properties of LTI systems?
References:-
1. Getting started with MATLAB by Rudra Pratap
2. Signals and systems by .Ramesh Babu
3. Signals and systems by A.Anand Kumar
4. Signals, systems and communications by B.P.Lathi
61
-
7/29/2019 bs lab.doc
62/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Experiment: 9
Gibbs phenomenon
Aim:-: Verification of Gibbs phenomenon on signals
Pre requisite:-
1. Study the details of Gibbs phenomenon
Apparatus Required:-
1. MATLAB 7.1
Program:-
clear all;close all;clc;t=linspace(-2,2,2000);u=linspace(-2,2,2000);sq=[zeros(1,500),2*ones(1,1000),zeros(1,500)];
k = 2;
N=[1,3,7,15,55,70];for n=1:6;an=[];for m=1:N(n)
an=[an,2*k*sin(m*pi/2)/(m*pi)];end;fN= 1 ;for m=1:N(n)
fN=fN+an(m)*cos(m*pi*t/2);end;nq=int2str(N(n));subplot(3,2,n);
plot(u,sq,'r','LineWidth',2);hold on;plot(t,fN,'LineWidth',2);hold off;axis([-2 2 -0.5 2.5]);grid;xlabel('--- > Time'),ylabel('--- > y_N(t)');title(['N = ',nq]);end;
62
-
7/29/2019 bs lab.doc
63/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
OUTPUT
Result:-
Viva questions:-
1. Define Gibbs Phenomenon?
2. What is the importance of Gibbs Phenomenon?
3. Applications of gibbs phenomenon?
References:-1. Getting started with MATLAB by Rudra Pratap
2. Signals and systems by .Ramesh Babu
3. Signals and systems by A.Anand Kumar
4. Signals, systems and communications by B.P.Lathi
63
-
7/29/2019 bs lab.doc
64/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Experiment: 10
Finding the Fourier Transform of a given signal
Aim:-To obtain the Fourier Transform of a given signal and plotting its Magnitude and Phase
spectrum.
Pre requisite:-
1. Study the Fourier Transform Concepts.
2. Study to find the Magnitude and Phase Spectrum of a given Signal.
Apparatus Required:-
1. MATLAB 7.1
Algorithm:-
Find the Fourier Transform and its Inverse Fourier Transform of a Signal
1. Clear all the global variables
2. Delete all existed figures in the window
3. Clear the command window
4. Specify the input function
5. Specify the function for fourier transform of given input
6. Display the output function (Xf)
7. Specify the function for inverse fourier transform of (Xf)
8. Display the output function (Xt)
Program:-clear all;close all;clc;syms x a bX = input('Fourier Transform of a function ....:: ');disp('is ......:: ');Xf = fourier(X)disp('Inverse Fourier Transform of a function ....:: ');Xf
disp('is ......:: ');Xt = ifourier(Xf)
OUTPUT
Fourier Transform of a function ....:: exp(-5*x)*heaviside(x)
is ......::
Xf = 1/(5+i*w)
Inverse Fourier Transform of a function ....::
64
-
7/29/2019 bs lab.doc
65/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Xf = 1/(5+i*w)
is ......::
Xt = exp(-5*x)*heaviside(x)
Algorithm:-
Find the Magnitude and Phase Spectrum of the above Signal
1. Clear all the global variables
2. Delete all existed figures in the window
3. Clear the command window
4. Specify the constant(angular frequency) value
5. Specify the function for magnitude of (Xf)
6. Plot the discrete signal for magnitude of (Xf)
7. Specify the function for phase angle of (Xf)
8. Plot the discrete signal for phase angle of (Xf)
Program:-clear all;close all;clc;w = -100:5:100;z = sqrt(25+w.*w);subplot(2,1,1);stem(w,z);xlabel('----> Frequency');ylabel('----> Magnitude');title('Magnitude plot');y = atan(-w/5);
subplot(2,1,2);stem(w,y);xlabel('----> Frequency');ylabel('----> Phase');title('Phase plot');
OUTPUT
65
-
7/29/2019 bs lab.doc
66/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Result:-
Viva questions:-
1. What is Fourier transform?2. What is the use of Fourier transform?
3. What is frequency spectrum?
4. What are the limitations of Fourier transform?
5. What is main lobe and side lobe?
Frequently asked questions:-
1. Give the expression for Fourier Transform?
2. Give the expression for Inverse Fourier Transform?
3. Find the Magnitude and Phase of x + i*y?
4. Find the Fourier Transform and find its Magnitude and Phase Spectrum
a) x(t) = U(t) b) x(t) = r(t)
c) x(t) = 2sin(10t)U(t) d) x(t) = exp(-|t|)U(t)5. Find the Fourier Transform and find its Magnitude and Phase Spectrum
References:-1. Getting started with MATLAB by Rudra Pratap
2. Signals and systems by .Ramesh Babu
3. Signals and systems by A.Anand Kumar
4. Signals, systems and communications by B.P.Lathi
66
-
7/29/2019 bs lab.doc
67/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Experiment: 11
Wave form synthesis using Laplace Transforms.
Aim:-To obtain wave form synthesis using Laplace Transforms.
Pre requisite:-
1. Study in detail about Laplace & Inverse Laplace Transforms.
Apparatus Required:-
1. MATLAB 7.1
Algorithm:-
Find the Fourier Transform and its Inverse Fourier Transform of a Signal
1. Clear all the global variables
2. Delete all existed figures in the window
3. Clear the command window
4. Specify the input function
5. Specify the function for laplace transform of given input
6. Display the output function (Xf)
7. Specify the function for inverse laplace transform of (Xf)
8. Display the output function (Xt)
Program:-
clear all;close all;clc;syms t a bX = input('Laplace Transform of a function ....:: ');disp('is ......:: ');Xf = laplace(X)
disp('Inverse Laplace Transform of a function ....:: ');Xfdisp('is ......:: ');Xt = ilaplace(Xf)
OUTPUT
Laplace Transform of a function ....:: sin(t) is ......::
Xf = 1/(s^2+1)
Inverse Laplace Transform of a function ....::
67
-
7/29/2019 bs lab.doc
68/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Xf = 1/(s^2+1) is ......::
Xt = sin(t)
Result:-
Viva questions:-
1. What is Waveform Synthesis?
2. What is the difference between Analysis and Synthesis?
3. What is Laplace transform?
4. What is ROC?
5. State initial value theorem?
Frequently asked questions:-
1. 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))
2. 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)
3. State final value thorm?
4. what are the diffrences between F.T and L.T ?
References:-
1. Getting started with MATLAB by Rudra Pratap
2. Signals and systems by .Ramesh Babu3. Signals and systems by A.Anand Kumar
4. Signals, systems and communications by B.P.Lathi
68
-
7/29/2019 bs lab.doc
69/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
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:-: Locating the zeros and poles and plotting the pole-zero maps in S-plane and Z-plane for the
given transfer function.
Pre requisite:-
1. Study the details of Laplace Transform and Z Transform in detail.
2. Learn to plot the poles and zeros in the S and Z planes
Apparatus Required:-
1. MATLAB 7.1
Algorithm:-
Location of poles and zeros in the S plane
1. Clear all the global variables
2. Delete all existed figures in the window
3. Clear the command window
4. Specify the input to enter the numerator coefficients
5. Specify the another input to enter the denominator coefficients
6. Specify the transfer function of given input
7. Specify functions for poles and zeros
8. Generate s-plane grid lines for a root locus or pole-zero map.
9. Specify the function to compute the poles and (transmission) zeros of the
LTI model SYS and plots them in the complex s plane.
Program:-
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)sgridpzmap(H)grid ontitle('Pole/Zero Plot for Complex Poles and Zeros in S plane');
OUTPUT
69
-
7/29/2019 bs lab.doc
70/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
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
Algorithm:-
Location of poles and zeros in the Z plane
1. Clear all the global variables
2. Delete all existed figures in the window
3. Clear the command window
4. Specify the input to enter the numerator coefficients
70
-
7/29/2019 bs lab.doc
71/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
5. Specify the another input to enter the denominator coefficients
6. Specify functions for poles and zeros
7. Generate z-plane grid lines for pole-zero map.
Program:-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');
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
Result:-
Viva questions:-
1. Study the details of sym() function?
2. Study the details of laplace() and ilaplace() functions?
3. Study the details of pretty() and factor() functions?
4. Study the details of Heaviside() function?
71
-
7/29/2019 bs lab.doc
72/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
5. Study the details of Residue() and roots() functions?
Frequently asked questions:-
1. Study the details of ztrans() and iztrans() functions?
2. Study the details of dimpulse() function?
3. What are Poles and Zeros?
4. How you Specify the Stability based on poles and zeros?
5. Define S plane and Z plane?
6. What is the difference between S plane and Z plane?
References:-
1. Getting started with MATLAB by Rudra Pratap
2. Signals and systems by .Ramesh Babu
3. Signals and systems by A.Anand Kumar
4. Signals, systems and communications by B.P.Lathi
Experiment: 13
72
-
7/29/2019 bs lab.doc
73/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Generation of Gauss ion noise (Real and Complex), computation of its
mean, M.S. value and PSD, probability distribution function.
Aim:-
: Generation of Gaussian noise (Real and Complex), computation of its mean, M.S. value and itsSkew, kurtosis, and PSD, probability distribution function.
Pre requisite:-
1.Learn about Gaussian noise and its importance
2.Study the details about mean, M.S. value and its Skew, kurtosis, and PSD, probability
distribution function
Apparatus Required:-
1. MATLAB 7.1
Program:-
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');subplot(2,2,[3,4]);plot(x);title('PSD of a normal Random Signal');xlabel('Sample Number');ylabel('Amplitude');
OUTPUT
73
-
7/29/2019 bs lab.doc
74/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Enter the number of samples ....:: 512
M =
-0.0398
K =
3.0770
V =
0.9535
Result:-
Viva questions:-1. Define Gaussian Noise?
2. Define Mean and Skew?
3. Define kurtosis and PSD?
4. Define CDF and PDF ?
5. What is the difference between CDF and PDF?
Experiment: 14
74
-
7/29/2019 bs lab.doc
75/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Sampling theorem verification.
Aim:-: Verification of Sampling Theorem
Pre requisite:-
1. Study the details of Sampling Theorem
Apparatus Required:-
1. MATLAB 7.1
Program:-
clear all;close all;clc;Fs = input('Enter Sampling Frequency in Hz ....:: ');Fm = input('Enter Message Frequency in Hz .....:: ');t = 0:0.01:2;msg = sin(2*pi*t);k = 2*Fs/Fm;step = ceil(201/k);samp_msg = [];for i = 1:201,
if (mod(i,step) == 0)samp_msg = [samp_msg,msg(i)];else
samp_msg = [samp_msg,zeros(1)];end;
end;subplot(2,1,1);plot(msg);xlabel('---> Time');ylabel('---> Amplitude');title('Msg signal');
subplot(2,1,2);stem(samp_msg);xlabel('---> Time');ylabel('---> Amplitude');if Fs < 2*Fm
title('Under Sampling');else if Fs == 2*Fm
title('Critical Sampling');else
title('Over Sampling');end;
end;
75
-
7/29/2019 bs lab.doc
76/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
OUTPUT
Enter Sampling Frequency in Hz ....:: 1200
Enter Message Frequency in Hz .....:: 60
Enter Sampling Frequency in Hz ....:: 100
Enter Message Frequency in Hz .....:: 60
76
-
7/29/2019 bs lab.doc
77/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Result:-
Viva questions:-
1. Define Sampling Theorem?
2. Define Replication property?
3. What is Impulse train?
4. Define sample & hold property?
References:-
1. Getting started with MATLAB by Rudra Pratap
2. Signals and systems by .Ramesh Babu
3. Signals and systems by A.Anand Kumar
4. Signals, systems and communications by B.P.Lathi
77
-
7/29/2019 bs lab.doc
78/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Experiment: 15
Removal of noise by auto correlation/cross correlation.
Aim:-:Removal of Noise by Auto Correlation/Cross Correlation.
Pre requisite:-
1. Study in detail about Noise factors and types of noise in Communication
2. Study the details of Correlation(Auto and Cross)
Apparatus Required:-
1. MATLAB 7.1
Program:-
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');
78
-
7/29/2019 bs lab.doc
79/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
OUTPUT
Enter the number of samples .....:: 150
Result:-
Viva questions:-1. What is a Noise and how many types of noises are there.
2. What is Gaussian noise?
3. What is Correlation? How many types of Correlations are there?
4. What is the difference between Auto and Cross Correlation
5. What is the importance of Correlation?
References:-
1. Getting started with MATLAB by Rudra Pratap
2. Signals and systems by .Ramesh Babu
3. Signals and systems by A.Anand Kumar
4. Signals, systems and communications by B.P.Lathi
79
-
7/29/2019 bs lab.doc
80/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Experiment: 16
Extraction of periodic signal masked by noise using correlation.
Aim:-:Extraction of periodic signal masked by noise using correlation.
Pre requisite:-
1. Study in detail about Noise factors and types of noise in Communication
2. Study the details of Correlation(Auto and Cross)
Apparatus Required:-
1. MATLAB 7.1
Program:-
clear all;close all;clc;N= input('Enter the number of samples .....:: ');M= input('Enter the number of cycles .....:: ');h=1/N;x=0:h:M;y=cos(3*pi*x);subplot(4,1,1);
plot(x,y);xlabel('---> time'); ylabel('-> Amplitude');title('Original signal');w=rand(1,M*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);subplot(4,1,4)plot(x,0.01*m(1:M*N+1));xlabel('---> time'); ylabel('-> Amplitude');title('Recovered signal');
OUTPUT
Enter the number of samples .....:: 100
Enter the number of cycles .....:: 4
80
-
7/29/2019 bs lab.doc
81/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
.
Result:-
Viva questions:-1. What is a Noise and how many types of noises are there.
2. What is Correlation? How many types of Correlations are there?
3. What is the difference between Auto and Cross Correlation
4. What is the importance of Correlation.References:-
1. Getting started with MATLAB by Rudra Pratap
2. Signals and systems by .Ramesh Babu
3. Signals and systems by A.Anand Kumar
4. Signals, systems and communications by B.P.Lathi
81
-
7/29/2019 bs lab.doc
82/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Experiment: 17
Verification of wiener Khinchine relations.
Aim:-: Verification of wiener Khinchine relations.
Pre requisite:-
5. Study in detail about Fourier Transform and its inverse.
6. Learn how to find the Fourier transform of the given function
7. Learn how to find the Power Spectrum of a given function
8. Learn how to find the Auto Correlation of a given function
9. Study the details of wiener Khinchine relations
Apparatus Required:-
1. MATLAB 7.1
Program:-
clear all;close all;clc;u=linspace(-2,2,5);sq=[ones(1,5)];stem(u,sq,'linewidth',2);
W = -3*pi:0.01:3*pi;k=sin(2.5*W)./sin(0.5*W);
subplot(2,1,1),plot(W,(k.*k));xlabel('----->Frequency');ylabel('------>Magnitude');title('Power Spectrum Using Fourier Transform');
c=xcorr(sq,sq);k=5+(2*cos(W))+(6*cos(2*W))+(4*cos(3*W))+(2*cos(4*W));z=k/4;
subplot(2,1,2), plot(W,(z.*z));xlabel('----->Frequency');ylabel('------>Magnitude');title('Power Spectrum Using Auto-Correlation');
82
-
7/29/2019 bs lab.doc
83/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
OUTPUT
Result:-
Viva questions:-1. Define Fourier Transform and its inverse?
2. What is the importance of Correlation?
3. What is the difference between Convolution and Correlation?
4. What is the importance of power spectrum?
5. Find the Fourier Transform of the following signals
a. x(t) = exp(-2*t)u(t)
b. x(t) = rect(0.5*t)
c. Trapezoidal function
6. Find the Auto Correlation of the above signalsReferences:-
1. Getting started with MATLAB by Rudra Pratap
2. Signals and systems by .Ramesh Babu
3. Signals and systems by A.Anand Kumar
4. Signals, systems and communications by B.P.Lathi
83
-
7/29/2019 bs lab.doc
84/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
Experiment:18
Checking a random process for stationary in wide sense
Aim:-: Checking a Random Process for Stationary in Wide Sense
Pre requisite:-
1. Study the details of Random Variables and Processes and types of Random Process
Apparatus Required:-
1. MATLAB 7.1
2. Windows XP SP2
Program:-
clear all;close all;clc;syms xz = input('Enter the function ..... :: ');Max = input('Max limit ....:: ');Min = input('Min limit ....:: ');
mean_value = int(z,Min,Max)y = subs(z,x,x+5);Auto_correlation = int(z*y,Min,Max)disp('If the mean value is constant .....');disp('and');disp('Auto Correlation is not a function of x variable ....');disp('then ');disp('The Random Process is Wide Sense tationary.');
OUTPUT
Enter the function ..... :: 10*cos(10*x + 100)
Max limit ....:: 2*pi
Min limit ....:: 0
mean_value =
0
Auto_correlation =
100*cos(50)*pi
84
-
7/29/2019 bs lab.doc
85/85
RAMAPPA ENGINEERING COLLEGE BASIC SIMULATION LAB
If the mean value is constant .....
and
Auto Correlation is not a function of x variable ....
then
The Random Process is Wide Sense stationary.
Result:-
Viva questions:-1. Define Random Variable and Random Process?
2. Define Mean, Median and Mode?
3. Define Auto Correlation?
4. What are the types of Random Process?
5. What is a Stationary Process?
6. What are the conditions for the Random Process to be WSS?
7. What are the conditions for the Random Process to be SSS?
References:-
1. Getting started with MATLAB by Rudra Pratap
2. Signals and systems by .Ramesh Babu
3. Signals and systems by A.Anand Kumar
4. Signals, systems and communications by B.P.Lathi