Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
The department imparts quality technical education with professional competence, leadership
abilities and ethical values through effective teaching learning process.
Course Outcomes
At the end of the successful competition of the course, the student will be able to
1. Generate different signals and sequences using MATLAB
2. Perform correlation and convolution of signals and sequences
3. Find the Fourier and Laplace transform of the given functions
4. Plot the pole-zero map of the given transfer function in S& Z planes
5. Find mean and variance & check the wide sense stationary of the Stochastic process
6. Remove the noise by auto correlation / cross correlation in a given signal corrupted by
noise.
Text
S.No Date Title of the Experiment Book- Page Marks Signature
Page No of the
No. staff
Part-A:
1 Introduction to Mat lab T1-1 1
Part-B: List of Experiments
(Any 16 programs can be executed)
1 Basic operations on matrices T1-25 9
Generation of various signals
2 T1-42 13
and sequences
Operations on signals and
3 T1-68 21
sequences
Finding even and odd
components & real and
4 T1-85 33
imaginary parts of a signal and
sequence
Verification of linearity property
5 T1-125 38
of a system
Verification of time invariance
6 T1-129 41
property of a system
Computation of unit impulse
7 and unit step response of a T1-145 44
system
Computation of frequency
8 T1-147 48
response of a system
Convolution between signals
9 T1-96 52
and sequences
Autocorrelation and cross
10 correlation between signals and T1-110 56
sequences
Finding the Fourier transform of
11 a given signal and plotting its T1-167 62
magnitude and phase Spectrum
Waveform synthesis using
12 T1-181 65
Laplace transform
13 Sampling theorem verification. T1-223 67
Generation of Gaussian noise
(Real and Complex),
computation of its mean,
14 T1-211 72
M.S.Value and its skew, kurtosis,
and PSD, Probability Distribution
Function.
Removal of noise by auto
correlation / cross correlation in
15 T1-234 79
a given signal corrupted by
noise.
Impulse response of a raised
16 T1-254 84
cosine filter.
Checking a Random Process for
17 T1-260 89
Stationary in Wide Sense
Verification of Wiener-
18 T1-268 92
Khintchine relations
Extraction of periodic signal
19 masked by noise using T1-244 95
correlation
Locating zeros and poles, and
plotting the pole-zero maps in s-
20 T1-189 99
plane and z-plane for the given
transfer function
Part C: Additional Experiment Beyond the Curriculum
21 Gibbs Phenomenon T1-158 101
Part- D
Lab Based Mini Project
TEXT BOOKS:
1.Basic Simulation Lab with MATLAB by Bhanu Bhaskara &Siddhartha Bhaskara,
TMH2011
2.Edward.W.Kamen & Bonnie.S.Heck, Fundamentals of Signals and Systems Using the
Web and MATLAB, 3e, Pearson 2014.
BASIC SIMULATION LABORATORY
PART-A INTRODUCTION TO
MATLAB
Part-A Module-1
Introduction to MATLAB
1. Introduction
Simulation is the imitation of the operation of a real-world process or system over time. The act
of simulating something first requires that a model be developed; this model represents the key
characteristics or behaviors/functions of the selected physical or abstract system or process.
The model represents the system itself, whereas the simulation represents the operation of
the system over time.
Invented in the year 1970 by Cleve Moler, and was modified by Jack little and Steve bangert.
MATLAB is numerical computing environment and programming language, used for applied
mathematics.
MATLAB was first adopted by control design engineers and spread to many other domains; it is
particularly used in education field and Industry/Scientific/Military applications.
MATLAB began with 80 functions, now it has over 8000 functions; MATLAB engineers
incorporated the LAPACK, BLAS libraries, embedding the state of the art software for matrix
computation.
MATLAB today has millions of users and a standard tool in both professional and academic use.
MATLAB is interactive system whose basic data element is an array that does not
require dimensioning. This allows solving many technical computing problems, especially those
with matrix and vector formulations, in a fraction of the time it would take to write a program in
a scalar non-interactive language such as C or FORTRAN.
statement presented to the command line is translated into language the computer understand
better and then immediately carried out.
MATLAB prompt (») in command window is where the commands are entered. Mat lab is
capable to interpret and evaluate the numerical matrices expressions as
b) on form of sequences of expressions which are saved in a text file, called m-file and execute
it in command window. Or
c)more rarely on form binary file which is called mex-files or file of extension .mex generated
from a C compiler
c) Current directory/Workspace:
The Current directory window displayed the list of all the files and folders under the
current directory, which happens to be the ‘work’ sub-directory, by default, under the
MATLAB root directory. Since the ‘MATLAB’ directory will normally be in the hard disk C:
/ in your system, where all the application software packages are stored, you should
never use the default directory for saving your MATLAB Files.
Workspace represents all the variables that are declared in Command Window.
relational operators such as <, > etc., and some special characters such as space,
(semicolon, ] etc., Evaluation of the expression produces a matrix.
MATLAB has 6 relational operators to make comparisons between variables. These are
== is equal to
~= is not equal to
Typical commands:
1. Whos
2. who
3. clear
4. quit
8. help
Certain MATLAB functions are essentially used on scalars, but operate element-wise
when applied to a matrix (or vector). They are summarized below.
7. exp - exponential
Other MATLAB functions operate essentially on vectors returning a scalar value. Some
of these functions are given below.
1. max- largest component: get the row in which the maximum element lies
Much of MATLAB’s power comes from its matrix functions. These can be further
separated into two sub-categories. The first one consists of convenient matrix building
functions, some of which are given below.
ans =
0.9092 0
0 0.5163 0
0 0.2661
2. Procedure:
2. Open the Matlab Editor by using File Tab --- --- -File on the Menu.
5. Perform error check if any, which is displayed on the Command window and Modify if
any.
7. Check the waveforms which are displayed on Figure window and plot them.
PART-B
LIST OF EXPERIMENTS
Experiment No.
Roll No:_____________
Date:______________
Objectives:
(A) To generate different matrices such as identity matrix, matrix with only zeros,
matrix with only ones and matrices with different sizes,
Apparatus:
Computer loaded with windows7 and MATLAB software
1Pre-Lab Questions:
_________________________________________________________________
__________________________________________________________________
__________________________________________________________________
4. Distinguish between element wise matrix multiplication and square of the matrix.
_________________________________________________________________
5. Give MATLAB commands to extract rows and columns from the matrices.
__________________________________________________________________
Program:
a=
8 1 6
3 5 7
4 9 2
>> sum(a) % find the sum of the elements in each column of matrix a%
ans =
15 15 15
b=
8 3 4
1 5 9
6 7 2
ans =
8
5
2
c=
6 1 8
7 5 3
2 9 4
ans =
-360
>> inv (a) % find the inverse of matrix a%
ans =
24 3 18
9 15 21
12 27 6
101 71 53
71 83 71
53 71 101
i=
1 0 0
0 1 0
0 0 1
1. For a matrix ‘b’, what is the difference between b*b and b.*b?
_______________________________________________________________
_______________________________________________________________
_______________________________________________________________
3. Write MATLAB code to find the square of the identity matrix of size 3x3.
______________________________________________________________
4. How can you find the sum of the elements in a column of matrix?
______________________________________________________________
Outcomes:
Experiment No:
Objectives:
(A). To generate various signals such as Unit impulse, Unit step, Square, Saw tooth,
Triangular, Sinusoidal, Ramp, Sinc Function.
(B). To generate various sequences such as Unit impulse, Unit step, Square, Saw
tooth, Triangular, Sinusoidal, Ramp, Sinc Function.
Apparatus:
1. What does MATLAB stand for and which version of MATLAB did you use?
----------------------------------------------------------------------------------------------------------------
4. How many toolboxes does MATLAB provide approximately? Name some of them.
----------------------------------------------------------------------------------------------------------------
5. Distinguish between continuous time and discrete time signals.
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
(A ) Program:
t=-20: 1:20
%--------------------Unit Impulse---------------------%
x=[zeros(1,20), 1,zeros(1,20)] %generate Unit Impulse Signal
figure(1), plot(t,x); % plot the generated Unit Impulse Signal
xlabel('t'); ylabel('x(t)'); title('Unit impulse Signal');
%------------------ Unit Step signal------------------%
y=[zeros(1,20), 1,ones(1,20)]
%y=[zeros(1,20),ones(20,1)] %generate Unit Step Signal
figure(2); plot(t,y); %Plot the generated unit step signal
xlabel('t'); ylabel('x(t)'); title('Unit Step Signal');
%---------------------- Ramp Signal------------------%
x1 = t;
x2 = 0;
x = x1.*(t>=0)+x2.*(t<0); %generate unit ramp signal
figure(3);plot(t,x); % plot the generated ramp signal
xlabel('t'); ylabel('x(t)'); title(' Ramp Signal');
%----------------------rectangular pulse------------%
t1=-10:0.01:10
a7=rectpuls(t1/10)
figure(4),plot(t1,a7), grid on,axis([-10 10 -2 2])
xlabel('time')
ylabel('magnitude')
title('rectangular pulse')
%-------------------- triangular pulse---------------%
t2=-10:0.1:10
a8=tripuls(t2)
figure(5),plot(t2,a8), grid on
title('triangular pulse')
xlabel('time')
ylabel('magnitude')
Expected Graphs:
(B) Program:
t=-20: 1:20
%--------------------Unit Impulse---------------------%
x=[zeros(1,20), 1,zeros(1,20)] %generate Unit Impulse Signal
figure(1), stem(t,x); % plot the generated Unit Impulse Signal
xlabel('t'); ylabel('x(t)'); title('Unit impulse Signal');
%------------------ Unit Step signal------------------%
y=[zeros(1,20), 1,ones(1,20)]
%y=[zeros(1,20),ones(20,1)] %generate Unit Step Signal
figure(2); stem(t,y); %Plot the generated unit step signal
xlabel('t'); ylabel('x(t)'); title('Unit Step Signal');
%---------------------- Ramp Signal------------------%
x1 = t;
x2 = 0;
x = x1.*(t>=0)+x2.*(t<0); %generate unit ramp signal
figure(3);stem(t,x); % plot the generated ramp signal
xlabel('t'); ylabel('x(t)'); title(' Ramp Signal');
%----------------------rectangular pulse------------%
t1=-10:0.1:10
a7=rectpuls(t1/10)
figure(4),stem(t1,a7), grid on,axis([-10 10 -2 2])
xlabel('time')
ylabel('magnitude')
title('rectangular pulse')
%-------------------- triangular pulse---------------%
t2=-10:0.1:10
a8=tripuls(t2)
figure(5),stem(t2,a8), grid on
title('triangular pulse')
xlabel('time')
ylabel('magnitude')
%--------------- Sinc Signal----------------------%
x = linspace(-5,5);
y = sinc(x);
figure(6);stem(x,y)
xlabel('time');
ylabel('amplitude');
title('sincfunction');
%-----------------Sinusoidal Signal----------------%
T = 20; %declare time period
F = 1/T; %compute frequency
x = sin(2*pi*F*t); %generate sinusoidal signal
figure(7);stem(t,x); % plot the generated sinusoidal signal
xlabel('t'); ylabel('x(t)'); title('sinusoidal Signal');
%---------------- Sawtooth signal-----------------%
fs = 1000;
t = 0:1/fs:1.5;
x = sawtooth(2*pi*50*t); %generate sawtooth signal
figure(8);stem(t,x); axis([0 0.2 -1 1]); %plot the generated sawtooth signal
xlabel('t'); ylabel('x(t)'); title('sawtooth Signal');
%----------------- square signal---------------------%
t=(0:0.01:10);
sq_wave=square(4*pi*t); %generate square signal
figure(9); stem(t,sq_wave); axis([0 5 -2 2]) %plot the generated square signal
xlabel('t'); ylabel('x(t)'); title('square signal');
%---------------------periodic triangle------------%
T=20;
x=linspace(0,5*T,1000);
y1=min(0.5,mod(x,T)/T);
y2=min(0.5,1-mod(x,T)/T);
figure(10),stem(x,y1+y2),grid on
xlabel('time')
ylabel('magnitude')
title('periodic triangle wave')
Expected Graphs:
----------------------------------------------------------------------------------------------------------------
2. Write a MATLAB code for generation of sinusoidal signal with frequency 50HZ.
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
4. Write a MATLAB code to plot a magnitude and phase of a complex exponential
signal.
----------------------------------------------------------------------------------------------------------------
5. Which MATLAB command divides the graphic space into six parts and select 5th part?
----------------------------------------------------------------------------------------------------------------
Outcomes:
Experiment No.
Objectives:
Apparatus:
3. Draw the schematic of a time delay system that delays the signal x(n) by k samples.
----------------------------------------------------------------------------------------------------------------
4. What do you mean by scaling a signal? Where do you find the need for scaling
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
5. Which operation shifts the signal towards right?
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
(A) Program:
title('multiplication');
ylabel('Amplitude')
xlabel('Time (s)')
% Amplitude scaling
t = [0:.01:1]; % independent (time) variable
A = 8; % amplitude
f1 = 2; % create a 2 Hz sine wave lasting 1 sec
s1 = A*sin(2*pi*f1*t);
subplot(3,1,1)
plot(s1);
xlabel('t');
ylabel('amplitude');
title('input signal');
s2=2*s1;
subplot(3,1,2)
plot(s2);
xlabel('t');
ylabel('amplitude');
title('amplified input signal');
s3=s1/2;
subplot(3,1,3)
plot(s3);
xlabel('t');
ylabel('amplitude');
title('attenuated input signal');
% Time scaling
t = [0:.05:pi]; % independent (time) variable
A = 8; % amplitude
f1 = 2; % create a 2 Hz sine wave lasting 1 sec
s1 = A*sin(2*pi*f1*t);
subplot(3,1,1)
plot(s1);
xlabel('t');
ylabel('amplitude');
title ('sine signal')
s2=A*sin(2*2*pi*f1*t); % scaling by a=4
subplot(3,1,2)
plot(s2);
xlabel('t');
ylabel('amplitude');
plot(nx,x);
xlabel('nx');ylabel('amplitude)');
title('original signal');
subplot(2,1,2);
plot(nf,xf);
xlabel('nf');
ylabel('amplitude');
title('folded signal');
%-------------------computation of energy and power---------------%
x=10*sin(10*pi*t);To=10
xsq=x.^2;
E = trapz(t,xsq);
P = E/(2*To);
disp([' Energy, E = ', num2str(E),' Joules']);
disp([' Power, P = ', num2str(P),' Watts'])
Expected Graphs:
(B) Program:
stem(s3);
xlabel('t');
ylabel('amplitude');
title('attenuated input signal');
% Time scaling
t = [0:.05:pi]; % independent (time) variable
A = 8; % amplitude
f1 = 2; % create a 2 Hz sine wave lasting 1 sec
s1 = A*sin(2*pi*f1*t);
subplot(3,1,1)
stem(s1);
xlabel('t');
ylabel('amplitude');
title ('sine signal')
s2=A*sin(2*2*pi*f1*t); % scaling by a=4
subplot(3,1,2)
stem(s2);
xlabel('t');
ylabel('amplitude');
title ('scaled sine signal with a=4')
s3=A*sin(.5*pi*f1*t); % scaling by a=1/4
subplot(3,1,3);
stem(s3);
xlabel('t');
ylabel('amplitude');
title ('scaled sine signal with a=1/4')
%--------------------time shifting---------------%
clc
clear all
close all
t = [0:.01:pi]; % independent (time) variable
A = 8; % amplitude
f1 = 2;
s1 = A*sin(2*pi*f1*t);
subplot(3,1,1)
stem(t,s1)
xlabel('t');
ylabel('amplitude');
title('input signal')
subplot(3,1,2)
stem(t+10,s1)
xlabel('t');
ylabel('amplitude');
title('right shifted signal')
subplot(3,1,3)
stem(t-10,s1)
xlabel('t');
ylabel('amplitude');
title('left shifted signal');
Expected Graphs:
----------------------------------------------------------------------------------------------------------------
2. Write a MATLAB code o multiply the following two vectors. Check manually if the
result is as desired. A=[1 2 3 4 5] B=[4 6 1 7 8]
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
3. Write a MATLAB code for to generate a random signal.
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
4. Which operation shifts the signal toward right?
----------------------------------------------------------------------------------------------------------------
5. When a signal is time advanced what type of a change occurs in it.
----------------------------------------------------------------------------------------------------------------
Outcomes:
Experiment No:
Objectives:
Apparatus:
1 Pre-Lab Questions:
_________________________________________________________________
__________________________________________________________________
__________________________________________________________________
_______________________________________________________________
Program (A):
n=-1:0.01:2;
s1=sin(2*pi*n)+cos(2*pi*n);
s2=sin(2*pi*(-n))+cos(2*pi*(-n));
figure(1)
subplot(2,1,1);
plot(n,s1);
title('signal s1');
xlabel('time');
ylabel('amplitude');
grid
subplot(2,1,2);
plot(n,s2);
title('signal s2');
xlabel('time');
ylabel('amplitude');
grid
x1=(s1+s2)/2;
x2=(s1-s2)/2;
figure(2)
subplot(2,1,1);
plot(n,x1);
title('even part');
xlabel('time');
ylabel('amplitude');
grid
subplot(2,1,2);
plot(n,x2);
title('odd part');title('signal s1');
xlabel('time');
ylabel('amplitude');
grid
Expected Graphs
signal s1
2
1
amplitude
-1
-2 complex signal
11-1 -0.5 0 0.5 1 1.5 2
10 time
signal s2
9
2
48.5 49 49.5 50 50.5 51 51.5
1
amplitude
-1
-2
-1 -0.5 0 0.5 1 1.5 2
time
even part
1
0.5
amplitude
-0.5
-1
-1 -0.5 0 0.5 1 1.5 2
time
signal s1
1
0.5
amplitude
-0.5
-1
-1 -0.5 0 0.5 1 1.5 2
time
Program (B):
x=-5:0.01:5;
a=sinh(x*0.1);
subplot(5,1,1);
plot(x,a), grid on %hyperbolic sine function%
title('hyperbolic sine function');
b=50+10i+sin(2*pi*x);
subplot(5,1,2);
plot(x,b);
title('second signal');
c=a+b;
subplot(5,1,3);
plot(c);
title('complex signal');
d=real(c);
subplot(5,1,4);
plot(d);
title('real part');
e=imag(d);
subplot(5,1,5);
plot(e);
title('imaginary part')
Expected Graphs
_____________________________________________________________
_______________________________________________________________
_______________________________________________________________
______________________________________________________________
Outcomes:
Experiment No.
Objectives:
Apparatus:
3. What are advantages of LTI systems because of which they are very popular.
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
(A )Program:
x2 =
3
enter the weighting value for first input a1= 4
a1 =
4
enter the weighting value for second input a2= 3
a2 =
3
f=
1
y=cos(x) is non-linear system
1. Draw the block diagram notation of a system representing its linearity property.
2. Write a MATLAB code for performing linearity property of arbitrary discrete time
systems.
3. Draw the block diagram of a discrete time system that represents the proof of its
linearity.
----------------------------------------------------------------------------------------------------------------
4. Write a MATLAB code to see if the system described by the following input-output
relationship is linear. Y(n)=x(n)-x(n-1)
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
Outcomes:
1. Clearly define linearity and time invariance properties of a discrete time system.
2. Write a MATLAB code for proving the linearity and time invariance property of
arbitrary discrete time systems.
Experiment No.
Objectives:
Apparatus:
3. What are advantages of LTI systems because of which they are very popular.
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
(A )Program:
1
y1 =
-0.4161
y2 =
-0.4161
y(n)=cos(x(n)) is time invariant system
1. Draw the block diagram notation of a system representing its time invariance
property.
2. Write a MATLAB code for performing the time invariance property of arbitrary
discrete time systems.
3. Draw the block diagram of a discrete time system that represents the proof of its
linearity.
----------------------------------------------------------------------------------------------------------------
4. Write a MATLAB code to see if the system described by the following input-output
relationship is time invariant. Y(n)=x(n)-x(n-1)
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
Outcomes:
Experiment No.
Objectives:
Apparatus:
1 Pre-Lab Questions:
_________________________________________________________________
__________________________________________________________________
__________________________________________________________________
Program (A):
i=impulse(sys);
figure(2);
plot(i);
title('impulse response');
xlabel('time');
ylabel('amplitude');
grid
enter the numerator polynomial=--2
enter the denominator polynomial=--[2,3]
sys =
2
-------
2s+3
Expected Graphs
step response
0.7
0.6
0.5
0.4
amplitude
0.3
0.2
0.1
0
0 20 40 60 80 100 120 140 160 180 200
time
impulse response
1
0.9
0.8
0.7
0.6
amplitude
0.5
0.4
0.3
0.2
0.1
0
0 20 40 60 80 100 120 140
time
Program (B)
_______________________________________________________________
______________________________________________________________
Outcomes:
Experiment No.
Objectives:
Apparatus:
1 Pre-Lab Questions:
_________________________________________________________________
__________________________________________________________________
3. What is the relation between polar form and rectangular form of a complex
function?
__________________________________________________________________
Program (A)
Expected Graphs
Real part
1
Amplitude 0.5
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
/
Imaginary part
0.5
Amplitude
-0.5
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
/
Magnitude Spectrum
1
Magnitude
0.5
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
/
Phase Spectrum
2
Phase(radians)
-1
-2
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
/
_______________________________________________________________
_______________________________________________________________
_______________________________________________________________
Outcomes:
Experiment No.
Objectives:
Apparatus:
3. Draw the block diagram representation of the input output relationship of an LTI
system.
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
5. Which mathematical equation represents the convolution between two sequences?
----------------------------------------------------------------------------------------------------------------
(A ) Program:
Expected Graphs:
(B) Program:
clear all;
x=[1,2,1,2,1,3,2];
N1=length(x);
n=0:1:N1-1;
subplot(2,2,1),stem(n,x);
xlabel('n'),ylabel('x(n)');
title('input sequence x(n)');
h=[1,-1,2,-2,1,1];
N2=length(h);
n1=0:1:N2-1;
subplot(2,2,2),stem(n1,h);
xlabel('n');ylabel('h(n)');
title('impulse signal h(n)');
y=conv(x,h);
n2=0:1:N1+N2-2;
subplot(2,1,2),stem(n2,y);
xlabel('n'),ylabel('y(n)'); title('convolution of 2 sequences x(n) and h(n)');
Expected Graphs:
Outcomes:
Experiment No.
Autocorrelation & Cross Correlation
Objectives:
(A). To generate various signals such as Unit impulse, Unit step, Square, Saw tooth,
Triangular, Sinusoidal, Ramp, Sinc Function.
(B). To generate various sequences such as Unit impulse, Unit step, Square, Saw
tooth, Triangular, Sinusoidal, Ramp, Sinc Function.
Apparatus:
3. What are the steps involved in the computation of correlation? How do they differ
when compared with those of convolution?
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
(A ) Program:
Expected Graphs:
(B) Program:
Expected Graphs:
1. How do you compute cross correlation between x and y using the ‘conv’ command?
2. Write MATLAB program to prove that the auto correlation between two discrete
time signals, without using the built-in ‘xcorr’ command.
3. Write MATLAB code for computing the cross correlation of two periodic sequences,
each of period N.
----------------------------------------------------------------------------------------------------------------
Outcomes:
Experiment No.
Finding the Fourier Transform of a given
Signal and Plotting its Magnitude and
11 Phase Spectrum
Objectives:
Write a matlab program for finding the Fourier Transform of a given signal and
plot its Magnitude and phase spectrum.
Apparatus:
----------------------------------------------------------------------------------------------------------------
4. Which equation specifies the magnitude and phase of spectral components of FT?
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
(A ) Program:
Expected Graphs:
2. What type of symmetry does the magnitude and phase spectra of FT possess?
----------------------------------------------------------------------------------------------------------------
4. Write a MATLAB program to find the Fourier transform of sinusoidal signal having
frequency 100Hz.
----------------------------------------------------------------------------------------------------------------
Outcomes:
Experiment No.
Objectives:
Write a matlab program for Wave form Synthesis using Laplace transform
Apparatus:
----------------------------------------------------------------------------------------------------------------
3. Define Region of Convergence (ROC).
----------------------------------------------------------------------------------------------------------------
(A ) Program:
Expected Output:
-5
-----------
s^2 - s + 2
(a)x_a(s)=a/(s^2+a^2)+s/(s^2+b^2)=(a*s^2+a*b^2+s^3+s*a^2)/(s^2+a^2)/(s^2+b^2)
(b)x_b(t)=a*ilaplace(s^2/(s^2+b^s),s,t)=a*ilaplace(s^2/(s^2+b^s),s,t)
Outcomes:
Experiment No.
Objectives:
Apparatus:
----------------------------------------------------------------------------------------------------------------
2. What do you understand by uniform sampling?
3. What is aliasing?
----------------------------------------------------------------------------------------------------------------
(A )Program:
The output
case(1)
enter the signal frequency20
enter the sampling frequency50
sampling theorem is satisfied
case(2)
enter the signal frequency20
enter the sampling frequency30
sampling theorem is not satisfied
Expected Graphs:
sinusoidal signal
1
0.8
0.6
0.4
0.2
amplitude
-0.2
-0.4
-0.6
-0.8
-1
0 0.5 1 1.5 2 2.5 3 3.5
time
Case(1): fs>2f
frequency plot
1
original signal, LSB&USB
0.9
0.8
0.7
0.6
amplitude
0.5
0.4
0.3
0.2
0.1
0
0 10 20 30 40 50 60 70
frequency
Case(2): fs<2f
frequency plot
1
original signal, LSB&USB
0.9
0.8
0.7
0.6
amplitude
0.5
0.4
0.3
0.2
0.1
0
0 5 10 15 20 25 30 35 40 45 50
frequency
----------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
Outcomes:
Experiment No.
Generation of Gaussian Noise, Computation of its
Mean, M.S.Values and Its Skew, Kurtosis
14 And Psd, Probability Distribution Function
Objectives:
Write a matlab program for generation of Gaussian noise, and computation of its mean,
mean square values, and its psd, probability distribution function.
Apparatus:
2. What is white Gaussian noise? How do you compare it with white uniform noise?
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
(A ) Program:
subplot(3,3,3);hist(pdfuniform1);
title('uniform probability histogram');
subplot(3,3,4);hist(pdfuniform1,100);
title('uniform probability ,100.bin histogram');
pdfmean=5;
pdfstd=7;
pdfnormalss=randn(1,10000)*(pdfstd+pdfmean);
subplot(3,3,5);hist(pdfnormalss);
title('normal distrubution with mean=5,std=7');
subplot(3,3,6);hist(pdfnormalss,100);
title('normal distrubution with mean=5,std=7');
%%%%%%%%%%%%%%%%%%%%%%%%%
x=randn([5 4])
k=kurtosis(x);
k1=skewness(x);
subplot(3,3,1);stem(k);
title('skew');
subplot(3,3,2);stem(k);
title('kurtosis');
%mean
x=normrnd(0,1,100,5);
xbar=(mean(x));
subplot(3,3,3);stem(xbar);
title('mean');
%median
xodd=1:5;
modd=median(xodd)
subplot(3,3,4);stem(modd);
title('odd median');
xeven=1:4;
meven=median(xeven)
subplot(3,3,5);stem(meven);
x=normrnd(0,1,100,6);
title('even median');
%standerd deviation
y=std(x)
subplot(3,3,6);stem(y);
title('standard deviation');
[n,p]=size(x);
x=x-ones(n,1)*mean(x);
y=x'*x/(n-1);
title('standard deviation');
%correlation
x=randn(30,4);
x(:,4)=sum(x,2);
[r,p]=corrcoef(x)
subplot(3,3,7);stem([r,p]);
title('correlation');
[i,j]=find(p<0.05);
[i,j]
%varience
x=[-1 1];
w=[1 3]
v1=var(x);
subplot(3,3,8);stem(v1);
title('varience');
%%%%%%%%%%%%%%%
Fs=1000;
t=0:1/Fs:1;
M=length(t);
w=randn(1,M);
x=cos(2*pi*200*t)+w;
h=spectrum.welch;
psd(h,x,'Fs',Fs);
Expected Graphs:
2. How does the mean and standard deviation affect the shape of Gaussian
distribution?
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
Outcomes:
Experiment No.
Removal of Noise by Autocorrelation and Cross
15 Correlation
Objectives:
Write a matlab program for removal of noise by autocorrelation & cross correlation
Apparatus:
3. State the formula for determining the signal to noise ratio in decibels?
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
(A ) Program:
N=1024;
f=1;
Fs=200;
n=0:N-1;
x=sin(2*pi*f*n/Fs);
y=x+10*randn(1,N);
subplot(3,1,1);plot(x);
title('pure sinewave');
grid;
subplot(3,1,2);plot(y);
title('y(n), puresinewave + noise');
grid;
Rxy=xcorr(x,y);
subplot(3,1,3);plot(Rxy);
title('cross correlation Rxy');
grid;
%%%%%%%%%%%%%%%%%%%%%%%
N=1024;
f1=1;
Fs=100;
n=0:N-1;
x=sin(2*pi*f1*n/Fs);
subplot(3,1,1);plot(x);title('pure sine wave');
grid;
x1=x+(10*randn(1,N));
subplot(3,1,2);
plot(x1);
title('pure sinewave + noise');
grid;
Rxx=xcorr(x,x1);
subplot(3,1,3);
plot(Rxx);
Expected Graphs:
1. When does the cross correlation between two signals become nearly zero?
2. Why can’t we filter out noise from noisy signal? Why should you use correlation to
do so?What are the steps involved in convolution operation?
Outcomes:
1. Write a MATLAB code for removing noise from a noisy periodic signal and calculate
its period.
Experiment No.
Objectives:
Apparatus:
2. State the purpose for which the raised cosine filters are normally used.
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
(A ) Program:
[y,t]=rcosflt(ones(10,1),1,8,'fir',.5,6);
%delay=6samples
[y1,t1]=rcosflt(ones(10,1),1,8,'fir',.5,8);
plot(t,y,t1,y1,'--');
peak=t(find(y==max(y)));
peak1=t1(find(y1==max(y1)));
pt=[min(peak),min(peak1)];
Expected Graphs:
(B) Program:
Department of Electronics and Communication Engineering 85
Basic Simulation Laboratory
%parametres
delay=3;
dataL=20;
R=0.5;
Fs=8;Fd=1;
PropD=0;
%generate random data at time 0,1Fd,2/Fd....
x=randsrc(dataL,1,[],1245);
tx=[PropD:PropD+dataL-1]./Fd;
%plot data
stem(tx,x);
xlabel('time');ylabel('amplitude');
%set axis&labels
axis([0 30 -1.5 1.5]);
%%%%%%%%%%%%%%%%%%%%%%%
clc;
t=-10:0.1:10;
%--------------------Unit Impulse---------------------%
x1=1;
x2=0;
x =x1.*(t==0); %generate Unit Impulse Signal
subplot(121), plot(x); % plot the generated Unit Impulse Signal
xlabel('t'); ylabel('x(t)'); title('Unit impulse Signal');
%--------------impulse response of raised cosine filter-----------%
y = rcosflt(x,1,8,'fir'); % Same as original example
% y = rcosflt(x,1,8,'fir/sqrt'); % FIR square-root RC filter
% y = rcosflt(x,1,8,'iir'); % IIR raised cosine filter
% y = rcosflt(x,1,8,'iir/sqrt'); % IIR square-root RC filter
% y = rcosflt(x,1,8,'fir'); subplot(122),plot(y)
Expected Graphs:
1. Which MATLAB command returns the impulse response of an FIR type RCF? What is
its syntax?
2. What is the so special about the impulse response of a raised cosine filter?
----------------------------------------------------------------------------------------------------------------
4. Have you heard about ‘root raised cosine filter’? How is it related to RCF?
----------------------------------------------------------------------------------------------------------------
Outcomes:
1. Represent the frequency response and the impulse response of raised cosine filter.
2. Define raised cosine filter and explain the applications in which it is used.
Experiment No.
Checking a Random Process for Stationary in Wide
17 Sense
Objectives:
Apparatus:
1. Define random process and distinguish between random variable and random
process
----------------------------------------------------------------------------------------------------------------
(A ) Program:
Expected Graphs:
1. Prove that the Gaussian random process generated using randn command is a WSS
process using MATLAB.
----------------------------------------------------------------------------------------------------------------
2. Which MATLAB command is used to fold the signal.
Outcomes:
1. Develop a MATLAB code for checking if a given random process is wide sense
stationary.
2. Classify the random processes.
Experiment No.
Objectives:
Apparatus:
1 Pre-Lab Questions:
_________________________________________________________________
6. Define fft.
__________________________________________________________________
_________________________________________________________________
Program (A)
Fs=100;
t=0:1/Fs:10;
x=sin(2*pi*15*t)+sin(2*pi*30*t);
N=512;
X=fft(x,N);
f=Fs*(0:N-1)/N;
Power=X.*conj(X)/N;
figure(1)
plot(f,Power)
title('Power Spectrum through fft');
xlabel('frequency f');
ylabel('power');
figure(2)
rxx=xcorr(x,x);
Sxx=fft(rxx,512);
plot(f, abs(Sxx))
title('Fourier transform of autocorrelation');
xlabel('frequency f');
ylabel('abs(Sxx)');
Expected Graphs
100
80
power
60
40
20
0
0 10 20 30 40 50 60 70 80 90 100
frequency f
4
x 10 Fourier transform of autocorrelation
3.5
2.5
abs(Sxx) 1.5
0.5
0
0 10 20 30 40 50 60 70 80 90 100
frequency f
_______________________________________________________________
_______________________________________________________________
_______________________________________________________________
Outcomes:
Experiment No.
Objectives:
Apparatus:
1 Pre-Lab Questions:
_________________________________________________________________
__________________________________________________________________
Program (A)
M=256;
n=0:M-1;
x=cos(16*pi/M)+sin(32*pi*n/M);
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);
for i=1:M
if rem(i-1,N)==0
d(i)=1
end;
end;
Cyd=ifft(fft(y,M).*fft(d,M))/M;
r=Cyd*(M/L);
figure(1);
plot(n,x,'b');
axis([1 80 -3 3])
xlabel('n');
ylabel('x(n)');
figure(2);
subplot(2,1,1);
plot(n,y, 'r');
xlabel('n');
ylabel('y(n)');
subplot(2,1,2);
stem(n,d);
xlabel('n');
ylabel('d(n)');
figure(3);
xlabel('n');
ylabel('r(n)');
figure(4);
axis([1 80 -3 3]);
axis([1 80 -3 3]);
1
x(n)
-1
-2
-3
10 20 30 40 50 60 70 80
n
2
y(n)
-2
10 20 30 40 50 60 70 80 90
n
0.5
1. Distinguish
0 between auto correlation and cross correlation.
0 0.1 0.2 0.3 0.4 0.5 0.6
________________________________________ 0.7 0.8 0.9 1
Experiment No.
Objectives:
Apparatus:
1 Pre-Lab Questions:
1. Define transfer function.
_________________________________________________________________
_________________________________________________________________
Program
zer = -0.5;
pol = 0.9*exp(j*2*pi*[-0.3 0.3]');
[b,a] = zp2tf(zer,pol,1);
fvtool(b,a);
figure(1);
fvtool(b,a,'Analysis','polezero')
figure(2);
zplane(b,a)
Expected Graphs
Pole/Zero Plot
0.5
Imaginary Part
0
-0.5
-1
-1.5 -1 -0.5 0 0.5 1 1.5
Real Part
_______________________________________________________________
_______________________________________________________________
______________________________________________________________
Outcomes:
Experiment No.
21 Gibbs Phenomenon
Objectives:
Apparatus:
3. State the difference between the two words ‘analysis’ and ‘synthesis’, in general
terms.
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
(A ) Program:
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,19,49,70];
for n=1:6;
an=[];
for m=1:N(n)
an=[an,2*K*sin(m*pi/2)/(m*pi)];
end;
fN=K/2;
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;
Expected Graphs:
3. State atleast three important observations that you made by observing all the
synthesized square-wave graphs?
----------------------------------------------------------------------------------------------------------------
Outcomes:
1. Write MATLAB code for observing the Gibbs phenomenon in graphical form.