You are on page 1of 114

SR ENGINEERING COLLEGE

Ananthasagar, Warangal.

BASIC SIMULATION LAB


II B. Tech I Semester

Laboratory Manual
List of Experiments

1. Basic Operations on Matrices.

2. Generation of Various Signals and Sequences (Periodic and Aperiodic), such as Unit Impulse,
Step, Square, Saw tooth, Triangular, Sinusoidal, Ramp and Sinc.

3. Operations on Signals and Sequences such as Addition, Multiplication, Scaling, Shifting,


Folding, Computation of Energy and Average Power.
4. Finding the Even & Odd parts of Signal 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 sample, unit step and sinusoidal responses of the given LTI system and verifying
its physical reliability and stability properties.
9. Gibbs Phenomenon
10. Finding the Fourier Transform of a given signal and plotting its magnitude and phase spectrum.
11. Waveform Synthesis using Laplace Transform.

12. Locating the Zeros and Poles and plotting the Pole-Zero maps in S plane and Z-Plane for the
given transfer function.

13. Generation of Gaussian noise (Real and Complex), Computation of its mean, M.S. Value and its
Skew, Kurtosis, and PSD, Probability Distribution Function.
14. Sampling Theorem Verification.
15. Removal of noise by Autocorrelation/ Cross correlation.
16. Extraction of Periodic Signal masked by noise using Correlation.
17. Verification of Weiner-Khinchine Relations.
18. Checking a Random Process for Stationarity in Wide sense.
Introduction:

MATLAB:

MATLAB (matrix laboratory) is a multi-paradigm numerical computing environment and fourth-


generation programming language. Developed by Math Works, MATLAB allows matrix
manipulations, plotting of functions and data, implementation of algorithms, creation of user
interfaces, and interfacing with programs written in other languages, including C, C++, Java,
Fortran and Python.

Although MATLAB is intended primarily for numerical computing, an optional toolbox uses the
MuPAD symbolic engine, allowing access to symbolic computing capabilities. An additional
package, Simulink, adds graphical multi-domain simulation and model-based design for dynamic
and embedded systems.

In 2004, MATLAB had around one million users across industry and academia. MATLAB users
come from various backgrounds of engineering, science, and economics. MATLAB is widely used
in academic and research institutions as well as industrial enterprises.

History:

Cleve Moler, the chairman of the computer science department at the University of New Mexico,
started developing MATLAB in the late 1970s. He designed it to give his students access to
LINPACK and EISPACK without them having to learn Fortran. It soon spread to other universities
and found a strong audience within the applied mathematics community. Jack Little, an engineer,
was exposed to it during a visit Moler made to Stanford University in 1983. Recognizing its
commercial potential, he joined with Moler and Steve Bangert. They rewrote MATLAB in C and
founded MathWorks in 1984 to continue its development. These rewritten libraries were known as
JACKPAC. In 2000, MATLAB was rewritten to use a newer set of libraries for matrix
manipulation, LAPACK.

MATLAB was first adopted by researchers and practitioners in control engineering, Little's
specialty, but quickly spread to many other domains. It is now also used in education, in particular
the teaching of linear algebra, numerical analysis, and is popular amongst scientists involved in
image processing.

Starting MATLAB:

After logging into your account, you can enter MATLAB by double-clicking on the MATLAB
shortcut icon (MATLAB 7.0.4) on your Windows desktop. When you start MATLAB, a special
window called the MATLAB desktop appears. The desktop is a window that contains other
windows.

The major tools within or accessible from the desktop are:

• The Command Window


• The Command History
• The Workspace
• The Current Directory
Steps to writing a program in matlab :
• The Help Browser
• The Start button

The graphical interface to the MATLAB workspace is shown bellow.



Common values: ( Like Time ex: t= 0 to 20 with increment of 2 t= (0:2:20)
Input 1: Formals of signal 1 or value1. ( x=input('value:'), x=20)
Input 2: Formal of signal 2 or value2.
output : Formula of output signal (x= a+b, x=a.*b)
Display Output: Locations of graph Plot(2,2,1) , disp(x),
Title: ( Output of Expt1: Sin signal)
X-Label ( x- lable is Amplitude, Voltage, Gain
Y-Label ( Y axis is Time, Frequency, Sequence)

Built in Functions:
1. Scalar Functions:

Certain MATLAB functions are essentially used on scalars, but operate element-wise when
applied to a matrix (or vector). They are summarized below.
1. sin - trigonometric sine
2. cos - trigonometric cosine
3. tan - trigonometric tangent
4. asin - trigonometric inverse sine (arcsine)
5. acos - trigonometric inverse cosine (arccosine)
6. atan - trigonometric inverse tangent (arctangent)
7. exp - exponential
8. log - natural logarithm
9. abs - absolute value
10. sqrt - square root
11. rem - remainder
12. round - round towards nearest integer
13. floor - round towards negative infinity
14. ceil - round towards positive infinity

2. Vector Functions:

Other MATLAB functions operate essentially on vectors returning a scalar value. Some of these
functions are given below.
1. max largest component : get the row in which the maximum element lies
2. min smallest component
3. length length of a vector
4. sort sort in ascending order
5. sum sum of elements
6. prod product of elements
7. median median value
8. mean mean value std standard deviation

3. Matrix Functions:

Much of MATLAB‟ s power comes from its matrix functions. These can be further separated into
two sub-categories.
The first one consists of convenient matrix building functions, some of which are given below.
1. eye - identity matrix
2. zeros - matrix of zeros
3. ones - matrix of ones
4. diag - extract diagonal of a matrix or create diagonal matrices
5. triu - upper triangular part of a matrix
6. tril - lower triangular part of a matrix
7. rand - randomly generated matrix
eg: diag([0.9092;0.5163;0.2661]) ans =
0.9092 0 0 0 0.5163 0 0 0 0.2661
commands in the second sub-category of matrix functions are
1. size- size of a matrix
2. det- determinant of a square matrix
3. inv- inverse of a matrix
4. rank- rank of a matrix
5. rref -reduced row echelon form
6. eig -eigenvalues and eigenvectors
7. poly -characteristic polynomial

New Commands:

1. CLC Clear command window.


CLC clears the command window and homes the cursor.

2. CLEAR Clear variables and functions from memory.


CLEAR removes all variables from the workspace.

3. CLOSE: Close figure.


CLOSE(H) closes the window with handle H.
CLOSE, by itself, closes the current figure window.
CLOSE('name') closes the named window.
CLOSE ALL closes all the open figure windows. CLOSE
ALL HIDDEN closes hidden windows as well.
STATUS = CLOSE(...) returns 1 if the specified windows were closed and 0 otherwise.

4. INPUT: Prompt for user input.


R = INPUT('What is your name','s') gives the prompt in the text string and waits for
character string input. The typed input is not evaluated; the characters are simply returned as
a MATLAB string. The text string for the prompt may contain one or more '\n'. The '\n'
means skip to the beginning of the next line. This allows the prompt string to span several
lines. To output just a '\' use '\\'.

5. DISP: Display array.


DISP(X) displays the array, without printing the array name. In all other ways it's the same
as leaving the semicolon off an expression except that empty arrays don't display.
If X is a string, the text is displayed
PROGRAM : 1. Basic operations on matrices

1. AIM :

Matlab program to perform Basic operations on matrices such as Addition, subtraction, multiplication
and inverse of Matrix.

2. Software Required:

Matlab software 7.0 and above.


OS: Windows.
3. THEORY:-

MATLAB, which stands for MATrix LABoratory, is a state-of-the-art mathematical software


package, which is used extensively in both academia and industry. It is an interactive program for
numerical computation and data visualization, which along with its programming capabilities provides
a very useful tool for almost all areas of science and engineering. Unlike other mathematical packages,
such as MAPLE or MATHEMATICA, MATLAB cannot perform symbolic manipulations without the
use of additional Toolboxes. It remains however, one of the leading software packages for numerical
computation.

As you might guess from its name, MATLAB deals mainly with matrices. A scalar is a 1-by-1
matrix and a row vector of length say 5, is a 1-by-5 matrix.. One of the many advantages of
MATLAB is the natural notation used. It looks a lot like the notation that you encounter in a linear
algebra. This makes the use of the program especially easy and it is what makes MATLAB a
natural choice for numerical computations. The purpose of this experiment is to familiarize
MATLAB, by introducing the basic features and commands of the program.

4. PROCEDURE:-

Step 1: Click on Matlab Icon in Despot or open matlab


  
Start All Programs MatlabR2010a Enter wait for 2-5 Seconds to load.
 
Step 2: As the Matlab window opens Go to File New Script for code
area. Step 3: Type the code / Program need to exicute.

Step 4: Save the program by pressing Ctrl + S or go to File Save ( Choose the
location to store all the Programs)

Step 5: To run the code Debug Run or Press F5.
Step 6: For Executions output response (if any Errors) Open Command Window.
Step 7: After Execution check Command window and Figure window for wave
form responses
Remembers:

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

5. Algorithm:

1.Clear the screen.


2. Close all the windows.
3. Input the First Matrix Variables as X.
4. Input the Second Matrix Variables as Y.
5. Find the Matrix A as Addition of X and Y.
6. Display the Value of matrix A;
7. Find the Matrix S as Subtraction of X and Y.
8. Display the Value of matrix S;
9. Find the Matrix I as Inverse of X and Y.
10. Display the Value of matrix I;
11. Find the Matrix D as Division of X and Y.
12. Display the Value of matrix D;

6. PROGRAM:
% Program for Basic Operations on Matrix
clear all;
close all;
clc;

%% Defining 2 matrices
x=input(' Enter the variables of X:');
y=input(' Enter the variables of Y:');

%%% Addition of matrices %%%


a=x+y;
disp('Output of Addition:');
disp(a);

%%% Subtraction of matrices %%%


s=x-y;
disp('Output of Subtraction:');
disp(s);

%%% Multiplication of matrices %%%


m=x*y;
disp('Output of Multiplication:');
disp(m);

%%% Inverse matrix %%%


i=inv(y);
disp('Output for Inverse of ');
disp(x);
disp(' The above output done by
<Name>…………. :');
%% End of the Program%%

VIVA QUESTIONS:-

1.Expand MATLAB?And importance of MATLAB?

2.What is clear all and close all will do?

3.What is disp() and input()?

4.What is the syntax to find the eigen values and eigenvectors of the matrix?

5. What is the syntax to find the rank of the matrix?

***
PROGRAM :2. Generation of Various Signals and Sequences.

1. AIM :

Matlab program to perform Generation of Various Signals and Sequences (Periodic and periodic),
such as Unit Impulse, Unit Step, Square, Saw tooth, triangular, Sinusoidal, Ramp, Sinc pulse.

2. Software Required:
Matlab software 7.0
and above

3. Theory: If the amplitude of the signal is defined at every instant of time then it is called
continuous signal. If the amplitude of the signal is defined at only at some instants of time
then it is called discrete signal. If the signal repeats itself at regular intervals then it is called
periodic signal. Otherwise they are called aperiodic signals.

EX: ramp, Impulse, unit step, sin- Periodic signals square, sawtooth, triangular sinusoidal –
periodic signals.

Ramp signal: r(t)= t when t>=0

Unit impulse signal:


Y(t) = 1 only when t=0
=0 other wise

Unit step signal:


u(t) = 1 only when t>=0
=0 other wise
Sinc signal: G(x)=(sinx)/x

Unit Impulse: The Unit Impulse function often referred to as diracdela function. It is the function
that defines the idea of a unit impulse in continuous-time. It is used to generate the system response
providing fundamental information about the system characteristics.
∫ δ(t)dt= 1
Unit Step function: The integral of the impulse function is a singularity function and is called
the unit step function represented as
U(n) = 0, n<0
= 1, n>=0
Square wave: The square wave is a periodic waveform consisting of Instantaneous transitions
between two levels.
Saw tooth wave: The saw tooth waveform is a non sinusoidal waveform based on its resemblance to
the teeth on the blade of a saw. A saw tooth generally ramps upward and then drops. The saw tooth
wave is one of the most common starting points used to create sounds.
Triangular wave: A triangle wave is a non-sinusoidal
waveform named for its triangular shape. The triangle
wave contains only odd harmonics.

Sinusoidal: The sine wave or sinusoid is a mathematical


function that describes a smooth repetitive oscillation. Its
most basic form as a function of time is
y(t) = Acos(wt)
Ramp function: The ramp function can be obtained as a linearly
increasing wave or exponentially increasing. It is defined as
r(t) = 0; t<0
= t; t>=0
Sinc Pulse: The sinc function, denoted by sinc(x) and sometimes as
Sa(x),
Sa(x) = sin(Пx)/Пx
The Fourier transform of the normalized sinc function is the
rectangular function with no scaling.

4. Program:

%Generation Of Impulse Sequence

subplot(2,2,4);
stem(y2);
xlabel('n');
ylabel('amplitude');
title('impulse sequence');

%Generation Of Unit Step Signal


n=-10:1:10;
y3=(n>=0);
figure;
subplot(2,2,1);
plot(n,y3);
xlabel('time');
ylabel('amplitude');
title('unit step signal');
%Generation Of Unit Step Sequence
subplot(2,2,2);
stem(n,y3);
xlabel('n');
ylabel('amplitude');
title('unit step sequence');

%Generation Of Square Wave signal


y4=square(2*pi*50*t); subplot(2,2,3);
plot(t,y4); axis([0
0.1 -2 2]);
xlabel('time');
ylabel('amplitude'); title('square wave
signal');

%Generation Of Square Wave Sequence


subplot(2,2,4);
stem(y4);
xlabel('n');
ylabel('amplitude');
title('square wave sequence');

%Generation Of Sawtooth Signal


y5=sawtooth(2*pi*50*t);
figure;
subplot(2,2,1);
plot(t,y5);
axis([0 0.1 -2 2]); xlabel('time');
ylabel('amplitude');
title('sawtooth wave signal');

%Generation Of Sawtooth Sequence


subplot(2,2,2);
stem(y5);
xlabel('n');
ylabel('amplitude');
title('sawtooth wave sequence');

%Generation Of Triangular Wave Signal


y6=sawtooth(2*pi*50*t,.5);
subplot(2,2,3);
plot(t,y6); axis([0
0.1 -2 2]);
xlabel('time');
ylabel('amplitude');
title(' triangular wave signal');
%Generation Of Triangular Wave Sequence
subplot(2,2,4);
stem(y6);
xlabel('n');
ylabel('amplitude');
title('triangular wave sequence');
%Generation Of Sinsoidal Wave Signal
y7=sin(2*pi*50*t);
figure;
subplot(2,2,1);
plot(t,y7);
axis([0 0.1 -2 2]); xlabel('time');
ylabel('amplitude');
title(' sinsoidal wave signal');
%Generation Of Sin Wave Sequence
subplot(2,2,2);
stem(y7);
xlabel('n');
ylabel('amplitude');
title('sin wave sequence');

%Generation Of Sinc
Signal t1=linspace(-
5,5); y8=sinc(t1);
subplot(2,2,3);
plot(t1,y8);
xlabel('time');
ylabel('amplitude');
title(' sinc signal');
%Generation Of Sinc Sequence
subplot(2,2,4);
stem(y8);
xlabel('n');
ylabel('amplitude'); title('sinc sequence');
VIVA QUESTIONS:-

1. Define Signal?

2. Define Determistic and Random Signal?

3. Define Delta Function?

4. What is Signal Modeling?

5. Define Periodic and a periodic Signal?

***
PROGRAM :3 Operations on Signals and Sequences

1. AIM:
To Perform the operations on signals and sequences such as addition , multiplication , scaling
. shifting , folding and also compute energy and power.

2. Software Required:
Matlab software 7.0 and above

3. Theory:
Signal
Addition
Addition: any two signals can be added to form a third signal, y (n) = x 1 (n) + y1 (n)

Multiplication :
Multiplication of two signals can be obtained by multiplying their values at every
instants y (n) = x1 (n)* y1 (n)

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

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


a >1 amplification

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

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

4. Algorithm: Generating Two Input Signals


1. Code the waveform1 as x1. Access this wave form for rest of all programs.
2. Code the waveform2 as x2. Access this wave form for rest of all programs.
3. Locate the Subplot then Plot the waveform x1 with respect to time t.
4. Locate the Subplot, give the title and labels.
5. Locate the Subplot then Plot the waveform x2 with respect to time t.
6. Give the title and labels.

5. Program:

% Program For Generation Of Signals

c lc;
clear all;
close all;
t=0:.01:1;
%Access this Time value for all the programs.

% Generating Two Input Signals


x1=sin(2*pi*4*t); % x1= sin
2pi4t x2=sin(2*pi*8*t);
subplot(2,2,1);
plot(t,x1);
xlabel('Time');
ylabel('Amplitude');
title('1. Signal1:Sine wave of frequency 4Hz');
subplot(2,2,2);
plot(t,x2);
xlabel('Time');
ylabel('Amplitude');
title('2. Signal2:sine wave of frequency 8Hz');

% Addition Of Signals
y1=x1+x2;
subplot(2,2,3);
plot(t,y1);
xlabel('Time');
ylabel('Amplitude');
title('3.Resultant Signal:Signal1+Signal2');

% Multiplication Of Signals
y2=x1.*x2;
subplot(2,2,4);
plot(t,y2);
xlabel('Time');
ylabel('Amplitude');
title('4. Resultant signal:Dot product of Signal1 & Signal2');

% Scaling Of A Signal
A=10;
y3=A*x1;
figure;
subplot(2,2,1);
plot(t,x1);
xlabel('Time');
ylabel('Amplitude');
title('5.1 Sine wave of frequency
4Hz') subplot(2,2,2);
plot(t,y3);
xlabel('Time');
ylabel('Amplitude');
title('5.2 Input signal1 ');

% FOLDING OF A SIGNAL
l1=length(x1); nx=0:l1-1;
subplot(2,2,3);
plot(nx,x1);
xlabel('nx');
ylabel('Amplitude');
title('6. Sine wave of frequency
4Hz') y4=fliplr(x1);
nf=-fliplr(nx);
subplot(2,2,4);
plot(nf,y4);
xlabel('nf');
ylabel('Amplitude');
title('6.2 Folded signal');
%SHIFTING OF ASIGNAL
figure;
t1=0:.01:pi;
x3=8*sin(2*pi*2*t1);
subplot(3,1,1);
plot(t1,x3);
xlabel('time t1');
ylabel('amplitude');
title('7.1 Sine wave of frequency 2Hz');
subplot(3,1,2);
plot(t1+10,x3);
xlabel('t1+10');
ylabel('amplitude');
title('7.2 right shifted
signal'); subplot(3,1,3);
plot(t1-10,x3); xlabel('t1-10');
ylabel('amplitude'); title('left
shifted signal');

% program for energy of a sequence


z1=input('Enter the input sequence:');
e1=sum(abs(z1).^2);
% program for energy of a
signal t=0:pi:10*pi;
z2=cos(2*pi*50*t).^2;
e2=sum(abs(z2).^2);
% program for power of a sequence

p1= (sum(abs(z1).^2))/length(z1);
% program for power of a signal
p2=(sum(abs(z2).^2))/length(z2);
VIVA QUESTIONS:

1. Define Symetric and Anti-Symmetric Signals?

2. Define Continuous and Discrete Time Signals?

3. What are the Different types of Operation performed on signals?

4. What is System?

***
PROGRAM :4. Even and Odd part of the signal and sequence

1. AIM: Finding even and odd part of the signal and sequence and also find real and
imaginary parts of signal.

2. Software Required:
Matlab software 7.0 and above.

3. Theory:
Even and odd part of a signal:
Any signal x(t) can be expressed as sum of even and odd components that is
X(t)=xe(t)+xo(t)

4. Algorithm:

% Even and odd parts of a signal


Step 1. Initialize Time period t.
Step 2. X as Sum of Odd and Even signals[ x=sint+cost]
Step 3. Give plot, label, titles for Input signal

Step 4. Y as Formula for Input signal with t=-t


Step 5. Give plot, label, titles for Input signal with t=-t

Step 6. Even part of the signal Z as signals sum of x and y


Step 7. Give Plot (in between t and z/2),label, titles for Input signal

Step 8. Odd part of the signal P as signals subtraction of x and y


Step 9. Give Plot (in between t and p/2),label, titles for Input signal
% Even and odd parts of a sequence
Step 1. Initialize value of z with real and conjugate values (ex: 0,2i+
4,5i+...) Step 2. Initial sequence 'n'

Step 3. Plot real parts of the sequence in between n and real values of z
Step 4. Give label, titles.

Step 5. Plot imaginary parts of the complex sequence between n and image of z Step
6. Give label, titles.
5. PROGRAM:

% Even And Odd Parts Of Signal And Sequence & Real And Imaginary Parts
clc;
close all;
clear all;
% Even and odd parts of a signal
t=0:.005:4*pi;
x=sin(t)+cos(t); % x(t)=sint(t)+cos(t)
subplot(2,2,1)
plot(t,x)
xlabel('t');
ylabel('amplitude')
title('input signal')
y=sin(-t)+cos(-t) % y=x(-t)
subplot(2,2,2)
plot(t,y)
xlabel('t');
ylabel('amplitude')
title('Input signal with t=-t')
z=x+y
subplot(2,2,3)
plot(t,z/2)
xlabel('t');
ylabel('Amplitude')
title('Even part of the signal')
p=x-y
subplot(2,2,4)
plot(t,p/2)
xlabel('t');
ylabel('Amplitude');
title('Odd part of the signal');

% Even and odd parts of a sequence


z=[0,2+j*4,-3+j*2,5-j*1,-2-j*4,-j*3,0];
n=-3:3
% plotting real and imginary parts of the sequence
figure;
subplot( 2,1,1);
stem(n,real(z));
xlabel('n');
ylabel('amplitude');
title('Real part of the complex sequence');
subplot( 2,1,2);
stem(n,imag(z));
xlabel('n');
ylabel('Amplitude');
title('Imaginary part of the complex sequence');
% complex conjugate of a signal
zc=conj(z);
zc_folded= fliplr(zc);
zc_even=.5*(z+zc_folded);
zc_odd=.5*(z-zc_folded);
% plotting even and odd parts of the sequence
figure; subplot( 2,2,1);
stem(n,real(zc_even));
xlabel('n');
ylabel('Amplitude');
title('Real part of the even
sequence'); subplot( 2,2,2);
stem(n,imag(zc_even));
xlabel('n');
ylabel('Amplitude');
title('Imaginary part of the even
sequence'); subplot( 2,2,3);
stem(n,real(zc_odd));
xlabel('n');
ylabel('Amplitude');
title('Real part of the odd
sequence'); subplot( 2,2,4);
stem(n,imag(zc_odd));
xlabel('n');
ylabel('Amplitude');
title('Imaginary part of the odd sequence');
VIVA QUESTIONS:

1. What is the formula to find odd part of signal?

2. What is Even Signal?

3. What is Odd Signal?

4. What is the formula to find even part of signal?

5.What is the difference b/w stem&plot?

****
PROGRAM: 5. Convolution of two sequences

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


sequences.

2. Software Required:
Matlab software 7.0 and above.

3. Theory:

Linear Convolution involves the following operations.


1. Folding
2. Multiplication
3. Addition
4. Shifting
These operations can be represented by a Mathematical Expression as follows

x[n]= Input signal Samples


h[ n-k]= Impulse response co-efficient.
y[ n]= Convolution output.
n = No. of Input samples
h = No. of Impulse response co-efficient. Example :
X(n)={1 2 -1 0 1}, h(n)={ 1,2,3,-1}.

5. Algorithm: Sequence Convolution

1. Clear and Close all previous data.


2. Get the input vales of 'x' sequence.
3. Get the input values of 'h' sequences.
4. Find the convolution of x and h by using direct function.
5. Plot the Discrete sequence of x and give title, labels.
6. Plot the Discrete sequence of h and give title, labels.
7. Plot the Convolution Discrete sequence of y and give title, labels.

Algorithm: Signal Convolution

1. Clear and Close all previous data.


2. Give the Time period value
3. Give the Waveform1 for x1.
4.Give the Waveform1 for h1.
5. Find the convolution of both waveforms x1 and h1 by using direct function.
6. Plot x1 and give title, labels.
7.Plot h1 and give title, labels.
8.Plot the Convolution y and give title, labels.
4. Program :
% for convolution of sequences
clc;
close all;
clear all;
%program for convolution of two sequences
x=input('Enter input sequence: x=');
h=input('Enter impulse response: h=');
y=conv(x,h);
subplot(3,1,1);
stem(x);
xlabel('n');
ylabel('x(n)');
title('Input signal')
subplot(3,1,2);
stem(h);
xlabel('n');
ylabel('h(n)');
title('Impulse response')
subplot(3,1,3);
stem(y);
xlabel('n');
ylabel('y(n)');
title('Linear convolution')
disp('The resultant signal
is'); disp(y);

Program :
% for convolution of signals:

t=0:0.1:10;
x1=sin(2*pi*t);
h1=cos(2*pi*t);
y1=conv(x1,h1);
figure;
subplot(3,1,1);
plot(t,x1);
xlabel('t');
ylabel('x(t)');
title('Input
signal')
subplot(3,1,2);
plot(t,h1);
xlabel('t');
ylabel('h(t)');
title('Impulse response')
subplot(3,1,3); plot(y1);
xlabel('n');
ylabel('y(n)');
title('Linear convolution');

VIVA QUESTIONS:-
1. Define Convolution?

2. Define Properties of Convolution?

3. What is the Difference Between Convolution& Correlation?

4. What are Dirchlet Condition?

5.What is Half Wave Symmetry?

***
PROGRAM : 6 Auto correlation and Cross correlation
1. AIM :

Write the program to compute Auto correlation and Cross correlation between signals
and sequences.

2. Software Required:
Mat lab software 7.0 and above

3. Theory:
Correlations of sequences:
It is a measure of the degree to which two sequences are similar. Given two real-valued
sequences x(n) and y(n) of finite energy, Convolution involves the following
operations.
1. Shifting
2. Multiplication
3. Addition

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


Cross correlation

The index l is called the shift or lag parameter


Autocorrelation

4. Algorithm:
Auto Correlation And Cross Correlation

Step 1. Input sequence for x


Step 2. Input sequence for y
Step 3. Stem x
Step 4. Give labels, title, location

Step 5. Stem h
Step 6. Give labels, title, location

Step 7. % cross correlation b/w 2 sequence


Step 8. Find cross correlating y by using faction to x,h
Step 9. Stem y
30
Step 10. Give labels, title, location

Step 11. % auto cross correlation of input sequence


Step 12. Find cross correlating z by using faction to x,x
Step 13. Stem z Step 14. Give labels, title, location

% Cross correlation between two signals


% Generating two input signals
Step 1. Initialize time
Step 2. Assign value for x1 with formula
Step 3. Assign value for h1 with formula
Step 4. Locate plot
Step 5. Plot x1 w.r.t time as input signal

Step 6. Locate plot


Step 7. Plot h1 w.r.to time as input signal
Step 8. % cross correlation
Step 9. Locate subplot
Step 10. Find z1 with function of cross correlation between x1,h1
Step 11. Give plot, labels, titles.
Step 12. % auto correlation
Step 13. Locate subplot
Step 14. Find z1 with function of cross correlation between x1,x1
Step 15. Give plot z2, labels, titles.

5. PROGRAM:

% Auto Correlation And Cross Correlation

clc;
close all;
clear all;

% Two Input Sequences


x=input('Enter input sequence: x=');
h=input('Enter the impulse sequence: h=');
subplot(2,2,1);
stem(x);
xlabel('n');
ylabel('x(n)');
title('Input sequence');
subplot(2,2,2);
stem(h);
xlabel('n');
ylabel('h(n)');
title('Impulse signal');
% Cross Correlation Between Two Sequences
y=xcorr(x,h);
subplot(2,2,3);
stem(y);
xlabel('n');
ylabel('y(n)');
title(' Cross correlation between two sequences ');
% auto correlation of input sequence
z=xcorr(x,x);
subplot(2,2,4);
stem(z);
xlabel('n');
ylabel('z(n)');
title('Auto correlation of input sequence');

% Cross Correlation Between Two Signals


% Generating Two Input Signals
t=0:0.2:10; x1=3*exp(-2*t);
h1=exp(t);
figure;
subplot(2,2,1);
plot(t,x1);
xlabel('t');
ylabel('x1(t)');
title('Input signal');
subplot(2,2,2);
plot(t,h1);
xlabel('t');
ylabel('h1(t)');
title('Impulse signal');

% Cross Correlation
subplot(2,2,3);
z1=xcorr(x1,h1);
plot(z1);
xlabel('t');
ylabel('z1(t)');
title('Cross correlation ');

% Auto Correlation
subplot(2,2,4);
z2=xcorr(x1,x1);
plot(z2); xlabel('t');
ylabel('z2(t)'); title('Auto
correlation ');

VIVA QUESTIONS:

1.Define Correlation?

2. Define Auto-Correlation?

3. Define Cross-Correlation?

4.What is the importance of correlation?

5.What is the difference b/w correlation and convolution?

***
PROGRAM:7(A). Verification Of Linearity Of A Discrete System

1.AIM :
Verify the Linearity of a given Discrete System

2. Software Required:
Mat lab software 7.0 and above

3. Theory:

Linearity property:

Any system is said to be linear if it satisfies the superposition principal. superposition principal
state that Response to a weighted sum of input signal equal to the corresponding weighted sum of
the outputs of the system to each of the individual input signals.
.

X(n)----------- input signal


Y(n) --------- output signal

Y(n)=T[x(n)]
Y1(n)=T[X1(n)] : Y2(n)=T[X2(n)]
x3=[a X1(n)] +b [X2(n) ]

Y3(n)= T [x3(n)]= T [a X1(n)] +b [X2(n) ] = a Y1(n)+ b [Y


Let a [Y1(n)]+ b [X2(n) ] =Z 3(n)

4. Algorithm:

Verification Of Linearity Of A Discrete System

% Entering two input sequences and impulse sequence


Step 1. Input samples of x1
Step 2. Input samples of x2
Step 3. Check for leanght of sequence equal or not
Step 4. Disp statues of error if sequences are not equals
Step 5. Input samples of h
Step 6. Find length of output sequence n for x1 and h
Step 7. Display length of output signal
Step 8. Display n
% Entering scaling factors
Step 9. Input scale factor a1,a2
Step 10. Find the x. ( x=a1x1+a2*x2)
Step 11. % response of x and x1
Step 12. find the yo1 as convolution of x, h
Step 13. Find the y1 as convolution of x1,h
% Scaled response of x1 Step 14. Y1s = a1 . Y1;
Step 15. % response of x2
Step 16. Find the value of y2 as convoluting of x2,h;

% Scaled response of x2

Step 17. Find the y1s as a2.y2.


Step 18. Find yo2 as y1a +y2s.
Step 19. Display input signal x1 and x2
Step 20. Give the condition if y01 and y02 are equal it is lti.

4. Program:

%%% Verification Of Linearity Of A Discrete System


clc;
clear all;
close all;
% Entering Two Input Sequences And Impulse Sequence
x1 = input (' type the samples of x1 ');
x2 = input (' type the samples of x2
'); if(length(x1)~=length(x2))
disp('error: Lengths of x1 and x2 are
different'); return;
end;
h = input (' type the samples of h ');
% length of output sequence
N = length(x1) + length(h) -1; disp('length
of the output signal will be '); disp(N);

% Entering Scaling Factors


a1 = input (' The scale factor a1 is
'); a2 = input (' The scale factor a2
is '); x = a1 * x1 + a2 * x2;
% response of x and x1
yo1 = conv(x,h);
y1 = conv(x1,h);

% Scaled Response Of X1
y1s = a1 * y1;
% response of x2
y2 = conv(x2,h);

% Scaled Response Of
X2 y2s = a2 * y2;
yo2 = y1s + y2s;
disp ('Input signal x1 is '); disp(x1); disp
('Input signal x2 is '); disp(x2);
disp ('Output Sequence yo1 is '); disp(yo1);
disp ('Output Sequence yo2 is '); disp(yo2); if
( yo1 == yo2 )
disp(' yo1 = yo2. Hence the LTI system is LINEAR ')
end;

PROGRAM 7(B):

1. AIM: Verify the Time Invariance of a given Discrete System.

2. Software Required:
Mat lab software 7.0 and above

3. Theory:

TIME INVARIENT SYSTEMS(TI):

A system is called time invariant if its input – output characteristics do not change with time

X(t)---- input : Y(t) ---output

X(t-T) -----delay input by T seconds : Y(t-T) ------ Delayed output by T seconds

4. Program:
clc;
clear all;
close
all;
% entering two input sequences
x = input( ' Type the samples of signal x(n) ' );
h = input( ' Type the samples of signal h(n) ' );
% original response
% y = conv(x,h);
disp( ' Enter a POSITIVE number for delay ');
d = input( ' Desired delay of the signal is ' ); %
delayed input
xd = [zeros(1,d), x];
nxd = 0 : length(xd)-1;

%delayed output
yd = conv(xd,h);
nyd = 0:length(yd)-1;
disp(' Original Input Signal x(n) is');
disp(x);
disp(' Delayed Input Signal xd(n) is');
disp(xd);
disp(' Original Output Signal y(n) is');
disp(y);
disp(' Delayed Output Signal yd(n) is');
disp(yd);
xp = [x , zeros(1,d)];
subplot(2,1,1);
stem(nxd,xp);
grid;
xlabel( ' Time Index n ');
ylabel( ' x(n) ' );
title( ' Original Input Signal x(n)');
subplot(2,1,2);
stem(nxd,xd);grid; xlabel( ' Time Index n ');
ylabel( ' xd(n) ' );
title( ' Delayed Input Signal xd(n) ');
yp = [y zeros(1,d)];
figure;
subplot(2,1,1);
stem(nyd,yp);
grid;
xlabel( ' Time Index n ' );
ylabel( ' y(n) ' );
title( ' Original Output Signal y(n) ');
subplot(2,1,2);
stem(nyd,yd);
grid;
xlabel( ' Time Index n ' );
ylabel( ' yd(n) ' );
title( ' Delayed Output Signal yd(n) ' );

VIVA QUESTIONS:

1. what is linearity.

2. what is time invariant of a system .

3.Condition for linearity of a system.

***
PROGRAM 8. Unit Sample, unit step and sinusoidal response of the given LTI system

1. AIM:
Compute the Unit sample, unit step and sinusoidal response of the given LTI system
and verifying its stability

2. Software Required:

Mat lab software 7.0 and above

3. Theory:
A discrete time system performs an operation on an input signal based on predefined criteria
to produce a modified output signal. The input signal x(n) is the system excitation, and y(n) is
the system response. The transform
operation is shown as,

If the input to the system is unit impulse i.e. x(n) = δ(n) then the output of the system is
known as impulse response denoted by h(n) where,
h(n) = T[δ(n)]
we know that any arbitrary sequence x(n) can be represented as a weighted sum of
discrete impulses. Now the system response is given by,

For linear system (1) reduces to

given difference equation y(n)-y(n-1)+.9y(n-2)=x(n);


%Given difference equation y(n)-y(n-1)+.9y(n-2)=x(n);
Assign value for b,a,n.
Generating impulse signal x1
Impulse response of h1 by using filter of a,b,x1.
Plot impulse response
Stem n and h1, give labels and titles.
Generating step signals for x2 as n value less then zero.

4. ALGORITHM:
Generating step response as s with function for b,a,x2/
Plot and stem for n,s and give labels and titles.
Generate sinusoidal response for h2 with fuction ( h2= filter ( b,a,x3))
Plot it then lable and title.
Verifing stability with zplane of b,a.

5. Program:
%Given Difference Equation Y(N)-Y(N-1)+.9y(N-2)=X(N);
b=[1];
a=[1,-1,.9];
n =0:3:100;

%Generating Impulse Signal x1=(n==0);

%Impulse Response
h1=filter(b,a,x1);
subplot(3,1,1);
stem(n,h1);
xlabel('n');
ylabel('h(n)');
title('Impulse Response');

%Generating Step Signal


x2=(n>0);
% Step Response
s=filter(b,a,x2);
subplot(3,1,2);
stem(n,s); xlabel('n');
ylabel('s(n)')
title('Step Response');

%Generating Sinusoidal Signal


t=0:0.1:2*pi;
`x3=sin(t);
% Sinusoidal Response
h2=filter(b,a,x3);
subplot(3,1,3);
stem(h2);
xlabel('n');
ylabel('h(n)');
title('Sin Response');

% Verifing Stability
figure; zplane(b,a);

VIVA QUESTION:

1.What operations can be performed on signals and sequence?

2.Define causality and stability?

3.Define scaling property and give its importance?

4. Define shifting property and give its importance?

5.Define folding property and give its importance?

***
PROGRAM :9. Gibbs phenomenon

1. AIM :
Verify the Gibbs phenomenon
2. Software Required:
Matlab software 7.0 and above.
3. Theory:
The GIBBS Phenomenon, The Fourier series of a piecewise continuously differentiable periodic
function behaves at a jump discontinuity. The n the approximated function shows amounts of
ripples at the points of discontinuity. This is known as the Gibbs Phenomina. partial sum of the
Fourier series has large oscillations near the jump, which might increase the maximum of the
partial sum above that of the function itself. The overshoot does not die out as the frequency
increases, but approaches a finite limit The Gibbs phenomenon involves both the fact that Fourier
sums overshoot at a jump discontinuity, and that this overshoot does not die out as the frequency
increases.

4. Program:
%%%Gibbs phenomenon
clc;
clear all;
close all;
t=0:0.1 :( pi*8);
y=sin(t);
subplot(5,1,1);
plot(t,y); xlabel('k');
ylabel('amplitude');
title('gibbs
phenomenon'); h=2;
%k=3;
for k=3:2:9
y=y+sin(k*t)/k; %fourier series of sin signal
subplot(5,1,h);
plot(t,y);
xlabel('k');
ylabel('amplitude');
h=h+1;
end
Viva questions:
1.Define Gibb’s Phenomenon?

2.What is the importance of Gibb’s Phenomenon?

3.What is Static and Dynamic System?

4.What is Causal Signal?

5.What is Causality Condition of the Signal?

***
PROGRAM :10 Fourier Transform of a given signal and plotting its magnitude and phase
spectrum.

1. AIM :

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

2. Software Required:
Matlab software 7.0 and above.

3. Theory:
Fourier Transform :
The Fourier transform as follows. Suppose that ƒ is a function which is zero outside of
some interval [−L/2, L/2]. Then for any T ≥ L we may expand ƒ in a Fourier series on the
interval

[−T/2,T/2], where the "amount" of the wave

2πinx/T
e in the Fourier series of ƒ is given by
By definition Fourier Transform of signal f(t) is defined as

Iverse Fourier Transform of signal F(w) is defined as

Program:
% Fourier transform of a given signal and plotting its magnitude and phase spectrum clc;
clear all;
close all;
fs=1000;
N=1024; % Length Of FFT Sequence
t=[0:N-1]*(1/fs);

% Input Signal x=0.8*cos(2*pi*100*t);


subplot(3,1,1); plot(t,x);
axis([0 0.05 -1 1]);
grid;
xlabel('t');
ylabel('amplitude');
title('input signal');

% Magnitude Spectrum
x1=fft(x);
k=0:N-1;
Xmag=abs(x1);
subplot(3,1,2);
plot(k,Xmag);
grid;
xlabel('t');
ylabel('amplitude');
title('Magnitude Of Fft Signal')

%Phase Spectrum
Xphase=angle(x1)*(180/pi);
subplot(3,1,3);
plot(k,Xphase);
grid;
xlabel('t');
ylabel('angle in degrees');
title('Phase Of Fft
Signal');

VIVA QUESTIONS:-

1.Define Fourier Series?

2.What are the properties of Continuous-Time Fourier Series?

3. What is the Sufficient condition for the existence of F.T?

4. Define the F.T of a signal?

5. What is the difference b/w F.T&F.S?

***
ROGRAM 11(A): Laplace transform & Inverse Laplace transform

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

2. Software Required:
Matlab software 7.0 and above

3. Theory:
Bilateral Laplace transforms:

The Laplace transform of a signal f(t) can be defined as follows:

Inverse Laplace transform


The inverse Laplace transform is given by the following formula :

3. Program:

% Laplace Transforms & Inverse Laplace Transforms clc;


clear all;
close
all;
%representation of symbolic variables syms f t w
s; %laplace transform of t
f=t;
z=laplace(f);
disp('The laplace transform of f =');
disp(z);

% Laplace Transform Of Sin Signal


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

%Inverse Laplace Transform


y1=ilaplace(z);
disp('The inverse laplace transform of z
='); disp(y1); y2=ilaplace(v1);
disp('The inverse laplace transform of v1 =
'); disp(y2);
y3=ilaplace(v2);

disp('The inverse laplace transform of v2 =


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

PROGRAM
AIM :
Perform the waveform synthesis using Laplace transform of a given signal.

2. Software Required:
Matlab software 7.0 and above.

3. Theory:
Consider the square wave of period ‘T’which can be represented with unit step
functions as f(t)=u(t)-2u(t-T/2)+2u(t-T)-2u(t-3T/2)+………..

4. Program:
% Waveform Synthesis Using Laplace Transforms
clc;
clear all; close all;
syms s; T=1;
%representation of laplace
transform F1=1-exp(-T*s/2);
F2=s*(1+exp(-T*s/2));
F=F1/F2;
%inverse laplace
transform f=ilaplace(F);
disp('inverse laplace transform of
F='); disp(f);
%easy plot for
'f' ezplot(f);
VIVA QUESTIONS:-

1.Define Laplace-Transform?

2. What is the Condition for Convergence of the L.T?

3. What is the Region of Convergence(ROC)?

4. State the Shifting property of L.T?

5. State convolution Property of L.T?

***
PROGRAM 12. Locating poles and zeros and plotting pole-zero maps in s-plane and z-
plane

1. AIM :
Write the program for locating poles and zeros and plotting pole-zero maps in s-plane
and z-plane for the given transfer function.

2. Software Required:
Matlab software 7.0 and above.

3. Theory:

Z-transforms
The Z-transform, like many other integral transforms, can be defined as either a one-sided
or two-sided transform.

Bilateral Z-transform
The bilateral or two-sided Z-transform of a discrete-time signal x[n] is the function X(z) defined as

Unilateral Z-transform
Alternatively, in cases where x[n] is defined only for n ≥ 0, the single-sided or unilateral
Z-transform is defined as

jw
. Where Z= r.e

4. Program:

%Locating Poles And Zeros In S-Plane & Z-Plane clc;


clear all;
close all;

%Enter The Numerator And Denamenator Cofficients In Square Brackets


num=input('Enter the numerator cofficients:');

den=input('Enter the denamenator cofficients:'); %find the


transfer function using built-in function 'filt' H=filt(num,den)

%Find Locations Of Zeros


z=zero(H); disp('zeros
are at '); disp(z);

%Find Residues,Pole Locations And Gain Constant Of H(Z)

[r p k]=residuez(num,den);
disp('poles are at '); disp(p);
%plot the pole zero map in z-plane
zplane(num,den);
title('pole-zero map of LTI system in z-plane');

% Ploe-Zero Plot In S-Plane


H1=tf(num,den) % find transfer function H(s)
[p1,z1]=pzmap(H1); % find the locations of poles
and zeros disp('poles ar at ');disp(p1);
disp('zeros ar at
');disp(z1); figure;

%Plot The Pole-Zero Map In S-


Plane pzmap(H1);
title('pole-zero map of LTI system in s-plane');

VIVA QUESTIONS:-

1.Study the details of ztrans() and iztrans() functions?

2.What are poles and zeros?

3.How you specify the stability based on poles and zeros?

4.Define S-plane and Z-plane?

5.What is the difference b/w S-plane and Z-plane?


PROGRAM 13. Gaussian noise

1. AIM :
Write the program for generation of Gaussian noise and computation of its mean,
mean square value, skew, kurtosis and probability distribution function.

2 Software Required:
Matlab software 7.0 and above

3. Theory:
The Gaussian Noise Generator block generates discrete-time white Gaussian noise. You must
specify the Initial seed vector in the simulation.
The Mean Value and the Variance can be either scalars or vectors. If either of these is a scalar,
then the block applies the same value to each element of a sample-based output or each column of a
frame-based output. Individual elements or columns, respectively, are uncorrelated with each other.
When the Variance is a vector, its length must be the same as that of the Initial seed vector. In this
case, the covariance matrix is a diagonal matrix whose diagonal elements come from theVariance
vector. Since the off-diagonal elements are zero, the output Gaussian random variables are
uncorrelated.

When the Variance is a square matrix, it represents the covariance matrix. Its off-diagonal elements
are the correlations between pairs of output Gaussian random variables. In this case, theVariance
matrix must be positive definite, and it must be N-by-N, where N is the length of the
Initial seed.

The probability density function of n-dimensional Gaussian noise is


n −1/2 T −1
f(x)=((2π) detK) exp(−(x−μ) K (x−μ)/2)
where x is a length-n vector, K is the n-by-n covariance matrix, µ is the mean value vector, and the
superscript T indicates matrix transpose.

4.Program:

% Generation Of Gaussian Noise

clc;
clear all;
close
all;
%generates first set of 2000 samples of Gaussian distributedrandom numbers

x1=randn(1,2000);
%generates second set of 2000 samples of Gaussian distributed random numbers

x2=randn(1,2000);
%plot the joint distribution of both the sets using
dot. plot(x1,x2,'.');
title('scatter plot of gaussian distributed random numbers');
%generates two sets of 2000 samples of uniform distributed random numbers
x3=rand(1,2000);x4=rand(1,2000);
figure;
plot(x3,x4,'.');
title('scatter plot of uniform distributed
random numbers'); figure;
subplot(2,1,1);
%plot the histogram graph of x2

hist(x2);
title(' gaussian
distribution');
subplot(2,1,2);
%plot the histogram graph of
x4 hist(x4);
title(' uniform distribution');
ymu=mean(x2)
ymsq=sum(x2.^2)/length(x2 )
ysigma=std(x2) yvar=var(x2)
yskew=skewness(x2)
ykurt=kurtosis(x2)

VIVA QUESTIONS:-

1.What is a noise and how many types of noises are there?

2.What is gaussion noise?

3.What is correlation ?How many types of correlation are there?

4.State Paeseval’s energy theorem for a periodic signal? 5.What is


Signum function?

***
PROGRAM: 14. Sampling theorem
1.AIM :Verify the sampling Theorem

2. Software Required:
Matlab software 7.0 and above.

3. Theory:
Sampling Theorem:
A bandlimited signal can be reconstructed exactly if it is sampled at a rate at least twice the
maximum frequency component in it." Figure 1 shows a signal g(t) that is band limited.

Figure 1: Spectrum of bandlimited signal g(t)

The maximum frequency component of g(t) is fm. To recover the signal g(t) exactly from its
samples it has to be sampled at a rate fs ≥ 2fm. The minimum required sampling rate fs =
2fm is called ' Nyquist rate

4. Algorithm:
% Sampling

Step 1. Initialize time period


Step 2. Assign value for t
Step 3. Value for fm (ex: fm= 1/t)
Step 4. Assign wave equation for x (ex: x= cos 2pfmt)
Step 5. Plot continuous time signal with t,x.
Step 6. Give label title etc.

% discrete time signal with


fs<2fm Step 7. Initialise samples n1
Step 8. Initialise sampling frequencies fs1, fs2 and fs3
Step 9. Assign another wave equation for x1 (ex: x1= cos 2pfm/fs1 n1) Step
10. Locate plot for 'discrete time signal with fs<2fm' between n1,x1. Step
11. Give label title etc;

%'discrete time signal with


fs=2fm' Step 12. Initialise samples n2
Step 13. Assign another wave equation for x1 (ex: x2= cos 2pfm/fs2* n2)
Step 14. Plot 'discrete time signal with fs<2fm' between n2,x2.
Step 15. Give label title etc., %discrete time signal with fs>2fm
Step 16. Initialise samples n2
Step 17. Assign another wave equation for x1 (ex: x2= cos 2pfm/fs2* n2)
Step 18. Plot 'discrete time signal with fs<2fm' between
n2,x2. Step 19. Give label title etc;

5. Program:

%Sampling Theorem Verification

clc;
clear all;
close all;
t=-10:.01:10;
T=4;
fm=1/T;
x=cos(2*pi*fm*t);
subplot(2,2,1);
plot(t,x);
xlabel('time');
ylabel('x(t)');
title('Continous Time
Signal'); grid;

n1=-4:1:4;
fs1=1.6*fm;
fs2=2*fm;
fs3=8*fm;

x1=cos(2*pi*fm/fs1*n1);
subplot(2,2,2);
stem(n1,x1);
xlabel('time');
ylabel('x(n)');
title('Discrete Time Signal With Fs<2fm');
hold on;
subplot(2,2,2);
plot(n1,x1);
grid;

n2=-5:1:5;
x2=cos(2*pi*fm/fs2*n2);
subplot(2,2,3);
stem(n2,x2);
xlabel('time');
ylabel('x(n)');
title('Discrete Time Signal With Fs=2fm');
hold on;
subplot(2,2,3);
plot(n2,x2)
grid;
n3=-20:1:20; x3=cos(2*pi*fm/fs3*n3);
subplot(2,2,4); stem(n3,x3);
xlabel('time'); ylabel('x(n)');
title('discrete time signal with fs>2fm');
hold on;
subplot(2,2,4);
plot(n3,x3)
grid;

VIVA QUESTIONS:-
1.State Paeseval’s energy theorem for a periodic signal?

2. Define sampling Theorem?

3. What is Aliasing Effect?

4. what is Under sampling?

5. What is Over sampling?

***
PROGRAM 15.Removal of noise by using auto correlation

1. AIM: Write the program for Removal of noise by using auto correlation.

2. Software Required:
Matlab software 7.0 and above.

3. Theory:

Detection of a periodic signal masked by random noise is of great importance .The noise
signal encountered in practice is a signal with random amplitude variations. A signal is uncorrelated
with any periodic signal. If s(t) is a periodic signal and n(t) is a noise signal then T/2.

Lim 1/T ∫ S(t)n(t-T) dt=0 for all T


T--∞ -T/2
Qsn(T)= cross correlation function of s(t) and n(t) Then Qsn(T)=0

Detection of noise by Auto-Correlation:

S(t)=Periodic Signal (Transmitted) , mixed with a noise signal


n(t). Then f(t) is received signal is [s(t ) + n(t) ]
Let Qff(T) =Auto Correlation Function of
f(t) Qss(t) = Auto Correlation Function of
S(t) Qnn(T) = Auto Correlation Function of
n(t) T/2
Qff(T)= Lim 1/T ∫ f(t)f(t-T)
dt T--∞ -T/2
T/2
= Lim 1/T ∫ [s(t)+n(t)] [s(t-T)+n(t-T)]
dt T--∞ -T/2 =Qss(T)+Qnn(T)
+Qsn(T)+Qns(T)
The periodic signal s(t) and noise signal n(t) are
uncorrelated Qsn(t)=Qns(t)=0 ;
Then Qff(t)=Qss(t)+Qnn(t)
The Auto correlation function of a periodic signal is periodic of the same frequency and the Auto
correlation function of a non periodic signal is tends to zero for large value of T since s(t) is a
periodic signal and n(t) is non periodic signal so Qss(T) is a periodic where as aQnn(T) becomes
small for large values of T Therefore for sufficiently large values of T Qff(T) is equal to Qss(T).

4. Program:
% Detection of noise by Auto-Correlation
clc;
clear all; close all;
t=0:0.2:pi*8;
%input signal
s=sin(t);
subplot(6,1,1);
plot(s);
title('signal s');
xlabel('t');
ylabel('amplitude');
%generating noise
n = randn([1 126]);
%noisy signal
f=s+n;
subplot(6,1,2);
plot(f);
title('signal
f=s+n'); xlabel('t');
ylabel('amplitude');

%Aucorrelation Of Input
Signal as=xcorr(s,s);
subplot(6,1,3);
plot(as);
title('auto correlation of s');
xlabel('t'); ylabel('amplitude');
%a correlation of noise
signal an=xcorr(n,n);
subplot(6,1,4)
plot(an);
title('auto correlation of n');
xlabel('t');
ylabel('amplitude');

%Aucorrelation Of Transmitted
Signal cff=xcorr(f,f);
subplot(6,1,5);
plot(cff);
title('auto correlation of f');
xlabel('t');
ylabel('amplitude');
%aucorrelation of received
signal hh=as+an;
subplot(6,1,6);
plot(hh);
title('addition of as+an');
xlabel('t');
ylabel('amplitude');
VIVA QUESTIONS:-

1.What is Causal Signal?

2. What are the Different types of Systems?

3. What is Linear System?

4. What is Signum function?

5. What is Static and Dynamic System?

***
PROGRAM 16. Extraction of periodic signal using correlation.

1. AIM: Write the program for extraction of periodic signal using correlation.

2. Software Required:
Matlab software 7.0 and above.

3. Theory:
A signal is masked by noise can be detected either by correlation techniques or by filtering.
Actually, the two techniques are equivalent. The correlation technique is a measure of extraction of
a given signal in the time domain whereas filtering achieves exactly the same results in frequency
domain.

4. Program:

% Extraction of periodic signal masked by noise using Correlation

clear all;
close all;
clc;
t=0:0.1: pi*4;
%Input Signal1 s=sin(t);
subplot(7,1,1);
plot(s);
title('signal s');
xlabel('t');
ylabel('amplitude');
%input signal2
c=cos(t);
subplot(7,1,2);
plot(c); title('signal
c'); xlabel('t');
ylabel('amplitude');

%Generating Noise Signal


n = randn([1 126]);
%signal+noise
f=s+n;
subplot(7,1,3);
plot(f);
title('signal
f=s+n'); xlabel('t');
ylabel('amplitude');

%Crosscorrelation Of Signal1&Signal2
asc=xcorr(s,c);
subplot(7,1,4)
plot(asc);
title(' correlation of s and c');
xlabel('t');
ylabel('amplitude');

%Crosscorrelation Of Noise&Signal2
anc=xcorr(n,c);
subplot(7,1,5)
plot(anc);
title(' correlation of n and c');
xlabel('t');
ylabel('amplitude');
%Crosscorrelation Of F&Signal2
cfc=xcorr(f,c);
subplot(7,1,6)
plot(cfc);
title(' correlation of f and c');
xlabel('t');
ylabel('amplitude');
%extracting periodic signal
hh=asc+anc;
subplot(7,1,7)
plot(hh);
title('addition of sc+nc');
xlabel('t');
ylabel('amplitude');

VIVA QUESTIONS:-

1. State the relationship between PSD and ACF?

2. What is the integration of ramp signal?

3. Difference between vectors and signals?

4. What is the important of dot product over cross product in signals?

5. Define Hilbert transforms?

***
PROGRAM 17. Verification of wiener-Khinchine

1. AIM: To Verification of wiener-Khinchine relation using matlab program .

2. Software Required:
Matlab software 7.0 and above.

3. Theory:
The wiener-khinchin theorem states that the power spectral density of a wide sense
stationary random process is the fourier transform of the corresponding autocorrelation
function.

Continuous case:
Sxx(f)=∫rxx(T)e-j2πft dT

Where
rxx(T)=E[x(t)x*(t-
T)] Discrete case:
Sxx(f)=Σrxx[k]e-j2πkf
Where
rxx[k]=E[x(n)x*(n-k)]

3. Program:

%Verification of wiener-khinchin relation


clc;
clear all;
close all;
t=0:0.1:2*pi;
%input signal
x=sin(2*t);
subplot(3,1,1);
plot(x);
xlabel('time');
ylabel('amplitude');
title('input signal');

%Autocorrelation Of Input Signal


xu=xcorr(x,x);

%FFT Of Autocorrelation Signal


y=fft(xu);
subplot(3,1,2);
plot(abs(y));
xlabel('f');
ylabel('amplitude');
title('fft of autocorrelation of input signal');
%Fourier Transform Of Input Signal
y1=fft(x);

%Finding The Power Spectral Density


y2=(abs(y1)).^2;
subplot(3,1,3);
plot(y2);
xlabel('f');
ylabel('magnitude');
title('PSD of input signal');

VIVA QUESTIONS:-

1. What is mean wiener ‒khinchine relation?

2. Define fourier transform and its inverse?

3. What is the difference b/w convolution and correlation?

4. What is the importance of power spectrum?

5. What is the importance of correlation?

***
PROGRAM 18. Wide sense Of A Random Process

1. AIM: -
Checking a random process for stationarity in wide sense.

2. SOFTWARE REQURIED:-

1.MATLAB R2010a.
2.Windows XP

3. THEORY:-

A stationary process (or strict(ly) stationary process or strong(ly) stationary process) is a stochastic
process whose joint probability distribution does not change when shifted in time or space. As a
result, parameters such as the mean and variance, if they exist, also do not change over time or
position..Weak or wide-sense stationary A weaker form of stationary commonly employed in signal
processing is known as weak-sense stationary, wide-sense stationarity (WSS) or covariance
stationarity. WSS random processes only require that 1st and 2nd moments do not vary with respect
to time.

and autocorrelation function

The first property implies that the mean function m x(t) must be constant. The second property
implies that the correlation function depends only on the difference between t1 and t2 and only
needs to be indexed by one variable rather than two variables. Thus, instead of writing, Rx(t1-
t2,0)we usually abbreviate the notation and write

This also implies that the auto covariance depends only on _ = t1 − t2, since

Stationary and Non Stationary Random Process:

A random X(t) is stationary if its statistical properties are unchanged by a time shift in the time
origin. When the auto-Correlation function Rx(t, t+T ) of the random X(t) varies with time difference
T and the mean value of the random variable X(t1) is independent of the choicet1,then X(t) is said to
be stationary in the wide sense or wide-sense stationary . So a continuous- Time
random process X(t) which is WSS has the following
properties
1) E[X(t)]=μX(t)= μX(t+T)

2) The Autocorrelation function is written as a function of T that is RX(t,


t+T)=Rx(T)

If the statistical properties like mean value or moments depends on time then the random process is
said to be non-stationary.

When dealing with two random process X(t) and Y(t), we say that they are jointly wide-sense
stationary if each process is stationary in the wide-sense.
Rxy(t,t+T)=E[X(t)Y(t+T)]=Rxy(T).

4. PROGRAM:-

Clc;
Close all;
clear all
y = randn([1 40])
my=round(mean(y));
z=randn([1 40])
mz=round(mean(z));
vy=round(var(y));
vz=round(var(z));
t = sym('t','real'); h0=3;
x=y.*sin(h0*t)+z.*cos(h0*t);
mx=round(mean(x));
k=2; xk=y.*sin(h0*(t+k))+z.*cos(h0*(t+k));
x1=sin(h0*t)*sin(h0*(t+k));
x2=cos(h0*t)*cos(h0*(t+k)); c=vy*x1+vz*x1;

VIVA QUESTIONS:-

1. what is the condition for WSS random process?

2.Define random variable with examples?

3. Define random process with examples?

4. Difference between ACF and CCF?

5. what are the different noises?


***

You might also like