You are on page 1of 90

DEPARTMENT

OF
ELECTRONICS AND COMMUNICATION ENGINEERING

NAME OF THE LABORATORY: BASIC SIMULATION


YEAR AND SEM: II B.TECH I SEM (R16)
REGULATION/LAB CODE: R18/EC308ES

BASIC SIMULATION LABORATORY MANUAL

HOD PRINCIPAL
Basic Simulation Lab

DEPARTMENT VISION
To be recognized as a full-fledged center for learning and research in various fields of
Electronics and Communication Engineering through industrial collaboration and to provide
consultancy for solving the real time socio-economic problems.

DEPARTMENT MISSION
 To provide innovative teaching and learning in the contemporary technologies in
Electronics and Communication Engineering to support the professional aspirations of the
students.
 To promote innovation through research and development among faculty and students by
providing opportunities for inter-disciplinary learning in collaboration with industry. 
 To encourage professional development of students that will inculcate ethical values and
leadership skills while working with the community to address societal issues.

DEPT OF ECE 2
Basic Simulation Lab

Program Educational Objectives (PEO’s):

After 3-5 years from the year of graduation, our graduates will,

 With an exposure to the areas of VLSI, Embedded Systems, Signal / Image Processing,
Communications, Wave theory, and Electronic circuits in modern electronics and
communications environment.
 Demonstrate the impact of Electronics and Communications Engineering on the society,
ethical, social and professional responsibilities/implications of their work.
 With strong foundations in mathematical, scientific and engineering fundamentals
necessary to formulate, solve and analyze Electronics and communications. Engineering
problems.
 Have strong communication inter-personal skills, multicultural adoptability and to work
effectively in multidisciplinary teams.
 Engage life-long learning to become successful in their professional work.

 PEO 1: To be equipped with skills for solving complex real-world problems related to
VLSI, Embedded Systems, Signal/Image processing, and Digital and Wireless
Communication.

 PEO 2: To develop professional skills that will equip them to succeed in their careers
and encourage lifelong learning in advanced areas of Electronics and communications
and related fields.

 PEO 3: To communicate effectively, work collaboratively and exhibit high levels of


professionalism, moral and ethical responsibility.

 PEO 4: To develop the ability to understand and analyze engineering issues in a broader
perspective with ethical responsibility towards sustainable development.

DEPT OF ECE 3
Basic Simulation Lab

Program Outcomes(PO’s):
A graduate of the Electronics and Communication Engineering Program will demonstrate:
PO1: Engineering knowledge: Apply the knowledge of mathematics, science, engineering
fundamentals, and an engineering specialization to the solution of complex engineering
problems.
PO2: Problem analysis: Identify, formulate, review research literature, and analyze complex
engineering problems reaching substantiated conclusions using first principles of
mathematics, natural sciences, and engineering sciences.
PO3: Design/development of solutions: Design solutions for complex engineering problems
and design system components or processes that meet the specified needs with appropriate
consideration for the public health and safety, and the cultural, societal, and environmental
considerations.
PO4: Conduct investigations of complex problems: Use research-based knowledge and
research methods including design of experiments, analysis and interpretation of data, and
synthesis of the information to provide valid conclusions.
PO5: Modern tool usage: Create, select, and apply appropriate techniques, resources, and
modern engineering and IT tools including prediction and modeling to complex
engineering activities with an understanding of the limitations.
PO6: The engineer and society: Apply reasoning informed by the contextual knowledge to
assess societal, health, safety, legal and cultural issues and the consequent responsibilities
relevant to the professional engineering practice.
PO7: Environment and sustainability: Understand the impact of the professional engineering
solutions in societal and environmental contexts, and demonstrate the knowledge of, and
need for sustainable development.
PO8: Ethics: Apply ethical principles and commit to professional ethics and responsibilities and
norms of the engineering practice.
PO9: Individual and team work: Function effectively as an individual, and as a member or
leader in diverse teams, and in multidisciplinary settings.
PO10: Communication: Communicate effectively on complex engineering activities with the
engineering community and with society at large, such as, being able to comprehend and
write effective reports and design documentation, make effective presentations, and give
and receive clear instructions.
PO11: Project management and finance: Demonstrate knowledge and understanding of the

DEPT OF ECE 4
Basic Simulation Lab

engineering and management principles and apply these to one’s own work, as a member
and leader in a team, to manage projects and in multidisciplinary environments.
PO12: Life-long learning: Recognize the need for, and have the preparation and ability to engage
in independent and life-long learning in the broadest context of technological change.

DEPT OF ECE 5
Basic Simulation Lab

Program Specific Outcomes(PSO’s)

 PSO 1: Problem Solving Skills – Graduates will be able to apply their knowledge in
emerging electronics and communication engineering techniques to design solutions and
solve complex engineering problems.

 PSO 2: Professional Skills – Graduate will be able to think critically, communicate


effectively, and collaborate in teams through participation in co and extra-curricular
activities.

 PSO 3: Successful Career – Graduates will possess a solid foundation in Electronics and
Communications engineering that will enable them to grow in their profession and pursue
lifelong learning through post-graduation and professional development. 

 PSO 4: Society Impact – Graduate will be able to work with the community and
collaborate to develop technological solutions that would promote sustainable
development in the society.

Course Outcomes (CO’s)

Upon completion of this course, the student will be able to:

CO 1: Describe programming & simulation for engineering problems


CO 2: Analyze various types of signals and sequences
CO 3: Sketch the spectrum of a given signal using SCILAB/OCTAVE
CO 4: Apply convolution and correlation operations on different signals.
CO 5: Write basic mathematical, electrical, electronic problems in SCILAB/OCTAVE

DEPT OF ECE 6
Basic Simulation Lab

Laboratory: Maintenance
1. The respective Lab assistant takes care of maintenance of all the equipments in the
department.
2. All the activities of the lab maintenance are well documented.
3. Most of the repairing of the equipment is done by the lab assistant himself, except a few
repairing where, the work has to be done by the manufacturing company / vendor.
4. Maintenance registers are maintained to check the working of equipment and updated once
in a semester.
5. Equipment is sent for regular service according to requirement.
6. At the start of every semester the equipment of all the concerned Laboratories are tested by
the Lab in-charges.
7. Any Problem identified is brought to the notice of head of the department.
8. Maintenance of computers is taken care by Computer Science & Engineering department
9. Major repairs are outsourced by following the procedure of the institute.
i. The problematic equipments are checked, noted in the maintenance registers and
they are brought to the notice of HOD by the concerned lab faculty and lab
assistant.
ii. Then the equipment is checked whether it’s repairable or non-repairable, if minor
repairs are identified then they are repaired by our lab assistants.
iii. If non-repairable equipment is identified it will be kept in the same lab separately
for demonstration to students.
iv. If major repairs are identified then the request is forwarded to the vendors for
concerned technical people to repair the equipment.
v. The technical person comes to campus for repairing. This process will be
monitored by the concerned lab faculty.
Laboratory: Overall Ambience

1. All laboratories are well furnished.


2. Support Staff are allotted to maintain the cleanliness of the laboratory.
3. All laboratories have sufficient natural light, Air circulation,
4. Good ventilation with tubes and fans arrangement.
5. Overall ambience of laboratories is good.
6. The charts of basic modules/ components/ characteristics with respect to related subject
are displayed for information purpose.

DEPT OF ECE 7
Basic Simulation Lab

DEPT OF ECE 8
Basic Simulation Lab

INSTRUCTIONS FOR STUDENTS

These are the instructions for the students attending the lab:

 Before entering the lab the student should carry the following things (MANDATORY)
 Identity card issued by the college
 Class notes
 Lab observation book
 Lab Record
 Student must sign in and sign out in the register provided when attending the lab session
without fail.
 Come to the laboratory in time. Students, who are late more than 15 min., will not be
allowed to attend the lab.
 Students need to maintain 100% attendance in lab if not, strict action will be taken.
 All students must follow the Dress Code while in the laboratory.
 Foods, drinks are NOT allowed.
 All bags must be left at the indicated place.
 Refer to the lab staff if you need any help in using the lab.
 Respect the laboratory and its other users.
 Workplace must be kept clean and tidy after the experiment is completed.
 Read the manual carefully before coming to the laboratory and be sure about what you are
supposed to do.
 Do the experiments as per the instructions given in the manual.
 Copy all the programs to observation which are taught in class before attending the lab
session.
 Students are not supposed to use floppy disks, pen drives without permission of lab-in
charge.
 Lab records need to be submitted on or before the date of submission.

DEPT OF ECE 9
Basic Simulation Lab

DO’S
 Students must enter their details in login book.
 Turn off the computer when you are no longer using it.
 Report any broken plugs or exposed electrical wires to the lab in-charge immediately.
 Program must be executed with in the given time.
 Place the chairs properly before leaving the lab.
 Check the laboratory notice board regularly for updates.

DONT’S
 Do not bring any food or drinks near the computer.
 Do not open any irrelevant internet sites on lab computer.
 Do not use a flash drive on lab computers.
 Do not upload, delete or alter any software on the lab PC.
 Do not plug in external devices without scanning them for computer viruses.
 Do not attempt to repair, open, tamper or interfere with any of the computer, printing,
cabling, air conditioning or other equipment in the laboratory.

DEPT OF ECE 10
Basic Simulation Lab

CONTENTS
S.No Name of the Experiment Page No.
1 Basic operations on matrices
2 generation of various signals and sequences such as unit impulse, unit
step, square,sawtooth,triangular,sinusoidal,ramp,sinc
3 Operations on signals and sequences such as
addition,multiplication,scaling,shifting,folding,computation of energy
and power
4 finding the even and odd parts of signal/sequence and real and
imaginary parts of the signal
5 convolution for signals and sequences
6 auto correlation and cross correlation for signals & 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 realizability and stability
properties
9 Gibbs phenomenon simulation
10 Finding the Fourier transform of a given signal and plotting its
magnitude and phase spectrum.
11 waveform synthesis using Laplace transform
12 locating the poles and zeros and plotting the pole-zero maps in s-plane
and z-plane for the given transfer function
13 Generation of gausssian noise(real and complex), computation of it’s
mean,M.S.valueand its skew,kurtosis,and PSD ,probability distribution
function
14 sampling theorem verification
15 removal of noise by auto correlation/cross correlation
16 Extraction of periodic signal masked by noise using correlation
17 verification of weiner - khinchine relations
18 Checking a random process for stationarity in wide sense

DEPT OF ECE 11
Basic Simulation Lab

INTRODUCTION TO SCILAB

Scilab is a programming language associated with a rich collection of numerical algorithms


covering many aspects of scientific computing problems.

From the software point of view, Scilab is an interpreted language. This generally allows
to get faster development processes, because the user directly accesses a high-level language, with
a rich set of features provided by the library. The Scilab language is meant to be extended so that
user-defined data types can be defined with possibly overloaded operations. Scilab users can
develop their own modules so that they can solve their particular problems. The Scilab language
allows to dynamically compile and link other languages such as Fortran and C: this way, external
libraries can be used as if they were a part of Scilab built-in features. Scilab also interfaces
LabVIEW, a platform and development environment for a visual programming language from
National Instruments.

From the scientific point of view, Scilab comes with many features. At the very beginning
of Scilab, features were focused on linear algebra. But, rapidly, the number of features extended to
cover many areas of scientific computing. The following is a short list of its capabilities:
 Linear algebra, sparse matrices
 Polynomials and rational functions
 Interpolation, approximation
 Linear, quadratic and non linear optimization
 Ordinary Differential Equation solver and Differential Algebraic Equations solver
 Classic and robust control, Linear Matrix Inequality optimization
 Differentiable and non-differentiable optimization
 Signal processing
 Statistics.

Scilab provides many graphics features, including a set of plotting functions, which allows to
create 2D and 3D plots as well as user interfaces.

DEPT OF ECE 12
Basic Simulation Lab

The useful workspace in Scilab consists of several windows:

• The console for making calculations


• The editor for writing programs
• The graphics windows for displaying graphics

The general environment and the console


After double--‐clicking the icon to launch Scilab, Scilab environment by default consists of the
following docked windows–console, files and variables browsers, command history.

In the console after the prompt“-->“,just type a command and press the Enter key (Windows and
Linux) on the key board to obtain the corresponding result.
--> 57/4
ans =
14.25
It is possible to come back at any moment with the key board's arrow keys ← ↑ → ↓or with the
mouse. The left and right keys are used to change the instructions and the up and down keys are
used to come back on a previously executed command.

The editor
Typing directly into the console has two disadvantages: it is not possible to save the commands
and it is not easy to edit multiple lines of instruction. The editor is the appropriate tool to run
multiple instructions.

 To open the editor from the console, click on the first icon in the tool bar or on
Applications > SciNotes
 In the menu bar, the editor opens with a default file named “Untitled 1“
 Typing in the editor is like as in any word processor
 Any file can be saved by clicking on File > Save as

DEPT OF ECE 13
Basic Simulation Lab

 The extension “.sce“ at the end of a filename will launch automatically Scilab when
opening it (except Under Linux and Mac OSX)

 Click on Execute in the menu bar and select save and execute

The graphics window

 A graphics window opens automatically when making any plot. It is possible to plot
curves, surfaces, sequences of points
 To erase a previous plot, type clf (“clear figure“).
 To open another graphics window, type scf; (“set current figure“).
 If several graphic windows are open, you can choose in which the plot will be drawn by
typing scf(n); n for the graphics window number (mentioned on the top left).

DEPT OF ECE 14
Basic Simulation Lab

Experiment- 1
BASIC OPERATIONS ON MATRICES

AIM: Write a program to perform basic operation on matrices.

SOFTWARE REQUIRED: PC loaded with SCILAB software

THEORY:

Vectors are special forms of matrices and contain only one row or one column. Whereas
scalars are special forms of matrices and contain only one row and one column. A matrix
with one row is called row vector and a matrix with single column is called column vector.
PROCEDURE:

1. Click on SCILAB Icon

2. Click on launch scinotes

3. Type the program on editor window

4. Save the program with filename.sce extension

5. Execute the program and observe the output/wave forms

PROGRAM:

A = input('Enter the Matrix A ::');


B = input('Enter the Matrix B ::');
// Find the size of matrices
disp('The size of Matrix A is ..... :: ');
disp(size(A));
disp('The size of Matrix B is .....:: ');
disp(size(B));
// Addition of two matrices
disp('Addition of A and B Matrices is ..... :: ');
disp(A + B);
// Subtration of two matrices

DEPT OF ECE 15
Basic Simulation Lab

disp('Subtraction of A and B Matrices is .....:: ');

disp(A - B);
//Multiplication (ELEMENT BY ELEMENT) of two matrices
disp('Multiplication of A and B Matrices is ..... :: ');
disp(A .* B);
// Finding the Rank of the matrix
disp('Rank of Matrix A is ::');
disp(rank(A));
// Find the determinant of the matrix
disp('Determinant of Matrix A is ::');
disp(det(A));

// Find the trace of the matrix


disp('Trace of Matrix A is ::');
disp(trace(A));

//Find the Inverse of the matrix


disp('Inverse of Matrix A is ::');
disp(inv(A));

OUTPUT:
Enter the Matrix A ::[1 2 ; 2 3 ; ]
Enter the Matrix B ::[1 2 ; 2 3 ; ]
The size of Matrix A is .... ::
2. 2.
The size of Matrix B is....::
2. 2.
Addition of A and B Matrices is .... ::
2. 4.
4. 6.
DEPT OF ECE 16
Basic Simulation Lab

Subtraction of A and B Matrices is.....::


0. 0.
0. 0.

Multiplication of A and B Matrices is .....::


1. 4.
4. 9.
Rank of Matrix A is ::
2.

Determinant of Matrix A is ::
- 1.

Trace of Matrix A is ::
4.

Inverse of Matrix A is ::

- 3. 2.
2. - 1.

RESULT:

Hence basic operations on matrices are performed

VIVA –VOCE QUESTIONS:

1. Expand SCILAB? And importance of SCILAB?


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

DEPT OF ECE 17
Basic Simulation Lab

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 rank of the matrix?

DEPT OF ECE 18
Basic Simulation Lab

Experiment-2

GENERATION OF VARIOUS SIGNALS AND SEQUENCES SUCH AS


UNIT IMPULSE, UNIT STEP, SQUARE, SAWTOOTH, TRIANGULAR,
SINUSOIDAL, RAMP, SINC

AIM: Write a program to Generate various signals and sequences (Periodic and aperiodic), such
as Unit Impulse,Unit Step, Square, Saw tooth, Triangular, Sinusoidal, Ramp, Sinc.

SOFTWARE REQUIRED: PC loaded with SCI LAB software

THEORY:
If the amplitude of the signal is defined at every instant of time then it is called continuous time
signal. If the amplitude of the signal is defined at only at some instants of time then it is called
discrete time 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, sinc- Aperiodic signals


square,sawtooth,triangular sinusoidal – periodic signals.

Ramp signal: The ramp function is a unitary real function, easily computable as the mean of the
independent variable and its absolute value.This function is applied in engineering. The name
ramp function is derived from the appearance of its graph.

r(t) = t when t≥0

=0 else
Unit impulse signal: One of the more useful functions in the study of linear systems is the "unit
impulse function."An ideal impulse function is a function that is zero everywhere but at the origin,
where it is infinitely high. However, the area of the impulse is finite

DEPT OF ECE 19
Basic Simulation Lab

Y(t)= 1 when t=0


=0 other wise

Unit step signal: The unit step function and the impulse function are considered to be
fundamental functions in engineering, and it is strongly recommended that the reader becomes
very familiar with both of these functions.

=0 if t < 0
u(t) = 1 if t > 0
=1/2 If t=0
Sinc signal: There is a particular form that appears so frequently in communications engineering,
that we give it its own name. This function is called the "Sinc function”.

PROCEDURE:

1. Click on SCILAB Icon

2. Click on launch scinotes

3. Type the program on editor window

4. Save the program with filename.sce extension

5. Execute the program and observe the output/wave forms

PROGRAM:

//continuous ramp signal


t = 0 : 0.001 : 1;

DEPT OF ECE 20
Basic Simulation Lab

y = 0.5 * t;
plot( t , y );
xlabel ('--------->Time Index t (sec.)');
ylabel ('--------->Amplitude');
title ('Ramp Signal Sequence');

//discrete ramp signal


n = 0 : 0.1 : 1;
y = 0.5 * n;
plot2d3(n,y);
xlabel ('---------->Time Index n');

ylabel ('---------->Amplitude');
title ('Ramp Signal Sequence');

//continuous sinc signal


t=linspace(-10 , 10);
y=sinc(t);
plot(t,y);
xlabel("Time Index t (sec.)");
ylabel("Amplitude");
title("Sinc Signal Sequence");

//discrete sinc signal


n =linspace(-10 , 10);
y =sinc(n);
plot2d3(n,y);
xlabel("Time Index n");
ylabel("Amplitude");
title("Sinc Signal Sequence");

// continuous Sinusoidal Signal


a=input('Enter amplitude');
t=0:0.001:1;
p=a*sin(2*%pi*10*t);

plot(t,p);
title("Sinusoidal sequence");
xlabel("time");
ylabel("amplitude");
DEPT OF ECE 21
Basic Simulation Lab

// discrete sinuoidal signal


a=input('Enter magnitude');
n = 0:100;
x =a*sin(((2*0.05)*%pi)*n);
plot2d3(n,x);
title("Sinusoidal sequence");
xlabel("samples");
ylabel("magnitude");

// continuous square wave Signal:


a=input('Enter amplitude');
t=0:0.001:1;
d=a*squarewave(2*%pi*10*t);
plot(t,d);
xlabel (" --------- >Time Index t (sec.)");
ylabel (" --------- >Amplitude");
title ("Square Wave Signal Sequence");

// discrete square wave signal


a=input('Enter amplitude');
n=0 : 0.01 :1;

d=a*squarewave(2*%pi*10*n);
plot2d3(n,d);
xlabel (" --------- >Time Index n");
ylabel (" --------- >Amplitude");
title ("Square Wave Signal Sequence");

// Triangular Wave Signal

Fs = 20; // samples per second


t_total = 100; // seconds
n_samples = Fs * t_total;
t = linspace(0, t_total, n_samples);
f=40; // sound frequency
tri_wave=(2/%pi)*asin(sin(2*%pi*f*t));
plot(t,tri_wave);
xlabel ('---------->Time Index t (sec.)');
ylabel ('----------- >Amplitude');
title ('Triangular Wave Signal Sequence');

// traiangular wave sequence


Fs = 20; // samples per second
t_total = 10; // seconds
n_samples = Fs * t_total;
t = linspace(0, t_total, n_samples);

DEPT OF ECE 22
Basic Simulation Lab

f=40; // sound frequency


tri_wave=(2/%pi)*asin(sin(2*%pi*f*t));
plot(t,tri_wave);
xlabel ('---------->Time Index t (sec.)');
ylabel ('----------->Amplitude');
title ('Triangular Wave Signal Sequence');

// Sawtooth Wave Signal


Fs = 20; // samples per second
t_total = 10; // seconds
n_samples = Fs * t_total;
t = linspace(0, t_total, n_samples);
f=500; // sound frequency
// Sawtooth wave
saw_wave=2*(f*t-floor(0.5+f*t));
plot(t,saw_wave);
xlabel ("---------->Time Index t (sec.)");
ylabel ("----------->Amplitude");
title ("Sawtooth Wave Signal Sequence");

// sawtooth wave sequence


Fs = 20; // samples per second

t_total = 10; // seconds


n_samples = Fs * t_total;
n = linspace(0, t_total, n_samples);
f=500; // sound frequency
// Sawtooth wave
saw_wave=2*(f*n-floor(0.5+f*n));
plot2d3(n,saw_wave);
xlabel ("---------->Time Index ");
ylabel ("----------->Amplitude");
title ("Saw tooth Wave Signal Sequence");

// Unit Impulse Signal and Sequence:


t=-5:1:5;
a=[zeros(1,5) 1 zeros(1,5)];
k=input("enter the amplitude");
b=k*a;
subplot(2,1,1);
plot(t,b);
xlabel("impulse response", "amplitude", "time");
subplot(2,1,2);
plot2d3(t,b);
xlabel("impulse response", "amplitude", "time");

DEPT OF ECE 23
Basic Simulation Lab

// Unit Step Signal and Sequence:


// Discrete Signal
t=0:4;
y=ones(1,5);
subplot(2,1,1);
plot2d3 (t,y);
xlabel('time');
ylabel('amplitude');

title('Unit Step Discrete Signal');


// Continuous Signal
subplot(2,1,2);
plot(t,y);
xlabel('time');
ylabel('amplitude');
title('Unit Step Continuous Signal');

OUTPUT:

DEPT OF ECE 24
Basic Simulation Lab

DEPT OF ECE 25
Basic Simulation Lab

enter the amplitude 9

DEPT OF ECE 26
Basic Simulation Lab

RESULT:

Hence various signals & sequences are generated using SCILAB software
VIVA QUESTIONS:

1. Define Signal?
2. Define continuous and discrete Signals?
3. State the relation between step, ramp and Delta Functions?
4. Differentiate saw tooth and triangular signals?
5. Define Periodic and aperiodic Signal?

DEPT OF ECE 27
Basic Simulation Lab

Experiment -3

OPERATIONS ON SIGNALS AND SEQUENCES SUCH AS ADDITION,


MULTIPLICATION, SCALING, SHIFTING, FOLDING, COMPUTATION
OF ENERGY AND POWER

AIM: Write a program to perform the operations on signals and sequences such as addition,
multiplication, scaling, shifting, folding and also compute energy and power.

SOFTWARE REQUIRED: PC loaded with SCI LAB software.

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

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

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

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

DEPT OF ECE 28
Basic Simulation Lab

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:

Average power:

PROCEDURE:
1. Click on SCILAB Icon
2. Click on launch scinotes
3. Type the program on editor window
4. Save the program with filename.sce extension
5. Execute the program and observe the output/wave forms

PROGRAM:

// Addition
x=input('Enter the sequence 1=');
y=input('Enter the sequence 2=');

DEPT OF ECE 29
Basic Simulation Lab

m=length(x);
n=length(y);
if m>n
y=[y,zeros(1,m-n)];
else

x=[x,zeros(1,n-m)];
end
z=x+y;
disp(z,'Addition result of two unequal length sequences:=');
// Multiplication
x=input('Enter the sequence 1=');
y=input('Enter the sequence 2=');
m=length(x);
n=length(y);
if m>n
y=[y,zeros(1,m-n)];
else
x=[x,zeros(1,n-m)];
end
z = x.*y;

disp (z, ' Multiplication result of two unequal lengths equences:= ' );

// Folding Operation
x = input ( ' Enter the input sequence e := ' );
m = length (x);
s = input ( ' Enter the starting point of original signal=' );
h = s + m -1;
n = s :1: h;
subplot (2 ,1 ,1)
x_location = " o r i g i n ";
y_location = " o r i g i n ";
data_bounds = [ -5 ,0;5 ,5];
plot2d3 (n,x)
xlabel ( ' n===>' )
ylabel ( ' Ampl itude' )
title ( ' Original Sequence ' )
subplot (2 ,1 ,2)
x_location = " o r i g i n ";
y_location = " o r i g i n ";
data_bounds = [ -5 ,0;5 ,5];
plot2d3 (-n,x)
xlabel ( ' n===>' )
ylabel ( ' Ampl itude' )
title ( ' Folded Sequence ' )
// Scaling Operation
DEPT OF ECE 30
Basic Simulation Lab

x = input( ' Ent e r input Sequence := ' );


m = length(x);
s= input ( ' Enter starting point of originalsignal:= ' )
h = s+m-1;
n = s :1: h;
C = input( 'Ent e r Compression factor Time Scaling factor' )

n = s/C:1/C:h/C ;
subplot (2 ,2 ,3)
x_location = " o r i g i n ";
y_location = " o r i g i n ";
data_bounds = [ -10 ,0;10 ,10];
plot2d3 (n,x)
xlabel ( ' n===>' )
ylabel ( ' Ampl itude' )
title ( ' Time Scaling - Compressed Sequence ' )

// shifting operation

x = input ( ' Enter the input sequence := ' )


m = length (x);
lx = input ( ' Enter the starting point of original signal := ' )
hx = lx+m -1;
n = lx :1: hx;

subplot (3 ,1 ,1)
x_location = " o r i g i n ";
y_location = " o r i g i n ";
data_bounds = [ -10 ,0;10 ,10];
plot2d3 (n,x);
xlabel ( ' n===>' )
ylabel ( ' Ampl itdue' )
title ( ' Original Sequence' )
d = input ( ' Enter the delay := ' )
n = lx+d:1: hx+d;
subplot (3 ,1 ,2)
x_location = " o r i g i n ";
y_location = " o r i g i n ";
data_bounds = [ -10 ,0;10 ,10];
plot2d3 (n,x)
xlabel ( ' n===>' )
ylabel ( ' Amplitude' )
title ( ' Delayed Sequence ' )

// Energy and Average power


p = input('Enter the sequence ...:: ');
M = length(p);
disp(M)
DEPT OF ECE 31
Basic Simulation Lab

sum = 0;
for i = 1:M,
sum=sum +(i*i);
end;
disp('Energy of the given sequence is ..... :: ');
Energy =sum
disp(Energy);
disp('Average Power of the given sequence is ..... :: ');
Average_power = sum/M
disp(Average_power)

// Addition, multiplication, shifting, folding, and scaling of signals:

n1=0:7;
y1=[zeros(1,3),ones(1,5)];
y2=n1-2;
y3=n1/4;
y4=n1;
y5=y1+y2;
y6=y3.*y4;

subplot(3,2,1);
plot2d3 (n1,y1);
xlabel('time');

ylabel('amplitude');
title('Sample Signal');

subplot(3,2,2);
plot2d3 (n1,y2);
xlabel('time');
ylabel('amplitude');
title('Advancing Shifting Signal');

subplot(3,2,3);
plot2d3(n1,y3);
xlabel('time');
ylabel('amplitude');
title('scaling of Signals');

subplot(3,2,4);
plot2d3(n1,y4);
xlabel('time');
ylabel('amplitude');
title('Folded Signal');

subplot(3,2,5);

DEPT OF ECE 32
Basic Simulation Lab

plot2d3(n1,y5);
xlabel('time');
ylabel('amplitude');
title('Addition of Signals');

subplot(3,2,6);
plot2d3(n1,y6);
xlabel('time');
ylabel('amplitude');

title('Multiplication of Signals');

// Energy and Average power of a signal


t = 0:0.01:4;
s = cos(2*%pi*t);
M = length(s);
disp(M)
sum = 0;
for i = 1:M,
sum=sum+(i*i);
end;
disp('Energy of the given signal is ...... :: ');
Energy = sum
disp(Energy)
disp('Average Power of the given signal is ...... :: ');
Average_power = sum/M
disp(Average_power)

OUTPUT:
Enter the sequence 1=[1 2 3]
Enter the sequence 2=[2 3 4 5]

Addition result of two unequal length sequences:=


3. 5. 7. 5.

Enter the sequence 1=[1 2 3]


Enter the sequence 2=[2 3 4 5]
Multiplication result of two unequal lengths equences:=
2. 6. 12. 0.
Enter the input sequence e := [1 2 3 4 5]
Enter the starting point of original signal=2

DEPT OF ECE 33
Basic Simulation Lab

Enter input Sequence : = [5 6 7 8 9]


Enter starting point of original signal:= 5
Enter Compression factor Time Scaling factor 5

Enter the input sequence := [5 6 7 8 9]


Enter the starting point of original signal: = 5
Enter the d e l a y: = 2

DEPT OF ECE 34
Basic Simulation Lab

Enter the sequence ...:: [3 4 5 6 7]


5.
Energy of the given sequence is ..... ::
55.
Average Power of the given sequence is ..... ::
11.

401.
DEPT OF ECE 35
Basic Simulation Lab

Energy of the given signal is ..... :: 21574201.


Average Power of the given signal is ..... : 53801.

RESULT:-
Hence various operations on signals and sequences are performed.

VIVA QUESTIONS:-
1. Define Symmetric and Anti-Symmetric Signals?
2. Define Continuous and Discrete Time Signals?
3. What are the Different types of representation of discrete time signals?
4. What are the Different types of Operation performed on signals?
5. What is System?

DEPT OF ECE 36
Basic Simulation Lab

Experiment – 4

EVEN AND ODD PARTS OF SIGNAL AND SEQUENCE & REAL AND
IMAGINARY PARTS OF SIGNAL

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

SOFTWARE REQUIRED: PC loaded with SCI LAB software

THEORY:
One of characteristics of signal is symmetry that may be useful for signal analysis. Even signals
are symmetric around vertical axis, and Odd signals are symmetric about origin.
Even Signal: A signal is referred to as an even if it is identical to its time-reversed counterparts;
x(t) = x(-t).

Odd Signal: A signal is odd if x(t) = -x(-t). An odd signal must be 0 at t=0, in other words, odd
signal passes the origin. Using the definition of even and odd signal, any signal may be
decomposed into a sum of its even part, xe(t), and its odd part, xo(t), as follows
Even and odd part of a signal: Any signal x(t) can be expressed as sum of even and odd
components i.e .,
x(t)=xe(t)+xo(t)

DEPT OF ECE 37
Basic Simulation Lab

PROCEDURE:
1. Click on SCILAB Icon
2. Click on launch scinotes
3. Type the program on editor window
4. Save the program with filename.sce extension
5. Execute the program and observe the output/wave forms

PROGRAM:
// Even and Odd part of Signal:

clc;
t = 0:10;

x = 2*sin(t);
y = -x;
subplot(2,2,1);
plot2d3(x);
xlabel('Time ----> ');
ylabel('Amplitude ---->');
title('Original signal f(t)');

subplot(2,2,2);
plot2d3(y);
xlabel('Time ---- > ');
ylabel('Amplitude --- >');
title('Original signal f(-t)');

even =0.5*(x + y);


sbplot(2,2,3);
plot2d3(even);
xlabel('Time ---- > ');
ylabel('Amplitude --- >');
title('Even part');

odd = 0.5*(x - y);


subplot(2,2,4);
plot2d3(odd);
xlabel('Time ---- > ');
ylabel('Amplitude --- >');
title('Odd part');

DEPT OF ECE 38
Basic Simulation Lab

// Even and Odd part of Sequence:

clc;
x = input('Enter the sequence :: ');
y = -x;
subplot(2,2,1);
plot2d3(x);
xlabel('Time ----> ');
ylabel('Amplitude ---->');
title('Original signal f(t)');

subplot(2,2,2);
plot2d3(y);
xlabel('Time ---- > ');
ylabel('Amplitude ---->');
title('Original signal f(-t)');

even =0.5*(x + y);

subplot(2,2,3);
plot2d3(even);
xlabel('Time ---- > ');
ylabel('Amplitude ---->');
title('Even part');

odd = 0.5*(x - y);


subplot(2,2,4);
plot2d3(odd);
xlabel('Time ---- > ');
ylabel('Amplitude ---->');
title('Odd part');

// Real and Imaginary parts of even and odd signal:

clc
x = [0, 2+4*%i, -3+2*%i, 5-1*%i, -2-4*%i, -3*%i, 0]
n = -3 : 3;
xc = conj( x );
xc_folded = xc(: , $ : -1 : 1);
xc_even = 0.5 * [x + xc_folded];
xc_odd = 0.5 * [x - xc_folded];
subplot(2,1,1) ;
plot2d3(n , real(xc_even));
title('Real part of even signal xc(n)')
xlabel ( ' n ' );
ylabel ('Magnitude of Real (xc-even)');
subplot(2,1,2) ;

DEPT OF ECE 39
Basic Simulation Lab

plot2d3( n , imag(xc_even) )

title('Imaginary part of even signal xc(n)')


xlabel ( ' n ' );
ylabel ('Magnitude of Imag (xc-even)');
figure;
subplot(2,1,1) ;
plot2d3( n , real(xc_odd));
title('Real part of odd signal xc(n)')
xlabel ( ' n ' );
ylabel ('Magnitude of Real (xc-odd)');
subplot(2,1,2) ;
plot2d3( n , imag(xc_odd));
title('Imaginary part of odd signal xc(n)')
xlabel ( ' n ' );
ylabel ('Magnitude of Imag (xc-odd)');

OUTPUT:

Enter the sequence :: [1 2 3 4 3 2 1]


-->x
x =

1. 2. 3. 4. 3. 2. 1.
DEPT OF ECE 40
Basic Simulation Lab

-->y
y =

- 1. - 2. - 3. - 4. - 3. - 2. - 1.

DEPT OF ECE 41
Basic Simulation Lab

RESULT
Even and odd part of the signal and sequence, real and imaginary parts of signal are computed.

VIVA- VOCE 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?

DEPT OF ECE 42
Basic Simulation Lab

Experiment -5

CONVOLUTION FOR SIGNALS & SEQUENCES

AIM:

Write the program for convolution between two signals and also between two sequences.

SOFTWARE REQUIRED: PC loaded with SCI LAB software

THEORY:

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}
PROCEDURE:
1. Click on SCILAB Icon
2. Click on launch scinotes
3. Type the program on editor window
4. Save the program with filename.sce extension
5. Execute the program and observe the output/wave forms

DEPT OF ECE 43
Basic Simulation Lab

PROGRAM:
// Convolution of two Sequences
x=input('enter the seq1 :: ');
h=input('enter the seq2 :: ');
subplot(3,1,1);
plot2d3(x);
subplot(3,1,2);
plot2d3(h);
o = conv(x,h);
subplot(3,1,3);
plot2d3(o);

// Convolution of two Signals


t = 1:20;
x = sin(t);
h = squarewave(t);
subplot(3,1,1);
plot2d3(x);
subplot(3,1,2);
plot2d3(h);
o = conv(x,h);
subplot(3,1,3);
plot2d3(o);

OUTPUT:
enter the seq1 :: [1 2 3 4]
enter the seq2 :: [1 2 3 4]

DEPT OF ECE 44
Basic Simulation Lab

RESULT:
convolution between signals and sequences is computed.

VIVA QUESTIONS:

1. Define Convolution?
2. Define Properties of Convolution?
3. What is the Difference between Convolution& Correlation?
4. Define impulse response?
5. What is Half Wave Symmetry?

DEPT OF ECE 45
Basic Simulation Lab

Experiment – 6

AUTO CORRELATION & CROSS CORRELATION FOR SIGNALS &


SEQUENCES

AIM:

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

SOFTWARE REQUIRED: PC loaded with SCI LAB software

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,

Correlation involves the following operations.


1. Shifting
2. Multiplication
3. Addition
Types of correlation are 1. Cross correlation
2. Auto correlation
.
PROCEDURE:
1. Click on SCILAB Icon
2. Click on launch scinotes
3. Type the program on editor window
4. Save the program with filename.sce extension
5. Execute the program and observe the output/wave forms

PROGRAM:
// Auto correlation of a sequence
clc;
a = input('Enter the sequence .... :: ');
res = xcorr(a);
subplot(2,1,1);

DEPT OF ECE 46
Basic Simulation Lab

plot2d3(a);
xlabel('----> Samples');

ylabel(' --- > Amplitude');


title('Input Sequence');
subplot(2,1,2);
plot2d3(res);
xlabel(' --- > Samples');
ylabel(' --- > Amplitude');
title('Output Sequence');

// Auto correlation of a signal


clc;
t = 0:0.01:2;
a = cos(2 * %pi * t);
res = xcorr(a);
subplot(2,1,1);
plot(a);
xlabel(' --- > Samples');
ylabel(' --- > Amplitude');
title('Input Sequence');
subplot(2,1,2);
plot(res);
xlabel(' --- > Samples');
ylabel(' --- > Amplitude');
title('Output Sequence');

// Cross correlation of a two sequences


clc;
a = input('Enter the first sequence.... :: ');
b = input('Enter the second sequence .... :: ');
r =xcorr(a,b);
subplot(2,2,1);
plot2d3(a);
xlabel(' --- > Samples');
ylabel(' --- > Amplitude');
title('Input Sequence(1)');
subplot(2,2,2);
plot2d3(b);
xlabel(' --- > Samples');
ylabel(' --- > Amplitude');
title('Input Sequence(2)');
subplot(2,2,3);
plot2d3(r);
xlabel(' --- > Samples');
ylabel(' --- > Amplitude');

DEPT OF ECE 47
Basic Simulation Lab

title('Output Sequence');

// Cross correlation of a two signals


clc;
t = 0:0.01:2;
a = cos(2 *%pi * t);
b = sin(2 *%pi * t);
res = xcorr(a,b);
subplot(2,2,1);
plot(a);
xlabel(' --- > Samples');
ylabel(' --- > Amplitude');
title('Input signal(1)');
subplot(2,2,2);
plot(b);
xlabel(' --- > Samples');
ylabel(' --- > Amplitude');
title('Input Signal(2)');
subplot(2,2,3);
plot(res);
xlabel(' --- > Samples');
ylabel(' --- > Amplitude');
title('Output Signal');

OUTPUT:
Enter the sequence ..... :: [8 9 7 6 5]

DEPT OF ECE 48
Basic Simulation Lab

Enter the first sequence .........:: [1 2 3]


Enter the second sequence ....:: [1 2 4]

DEPT OF ECE 49
Basic Simulation Lab

RESULT:

Auto correlation and Cross correlation between signals and sequences is computed.

VIVA QUESTIONS:

1. Define Correlation? And its properties?


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?

DEPT OF ECE 50
Basic Simulation Lab

Experiment -7

VERIFICATION OF LINEARITY AND TIME INVARIANCE PROPERTIES


OF A GIVEN CONTINUOUS/DISCRETE SYSTEM

AIM: Write a program to Verify linearity and time invariance properties of a given
continuous/discrete system.

SOFTWARE REQUIRED: PC loaded with SCILAB software

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. If x(n) is a input signal and y(n) is
a output signal then
y(n)=T[x(n)]
y1(n)=T[x1(n)] and 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 y2(n)

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-k) -----delay input by k seconds : Y(t-k) -------Delayed output by k seconds
If Y(t)=T[X(t)] then Y(t-k)=T[X(t-k)] then system is time invariant system.

PROCEDURE:
1. Click on SCILAB Icon
2. Click on launch scinotes
3. Type the program on editor window
4. Save the program with filename.sce extension
5. Execute the program and observe the output/wave forms
DEPT OF ECE 51
Basic Simulation Lab

PROGRAM:
clc;
n=0:0.1:2;
a= -3; b= 5;
x1=cos(2*%pi*n);
x2=cos(3*%pi*n);
x=a*x1+b*x2;
ic=[0 0];
num=[2.2403 2.4908 2.2403];
den=[1 -0.4 0.75];

y1=filter (num, den, x1, ic);


y2=filter(num,den,x2,ic);
y=filter (num, den, x, ic);
yt=a*y1+b*y2;
d=y-yt;

subplot (3,1,1);
plot2d3 (n,y);
xlabel('---------> Time');
ylabel('-> Amplitude');
title('y = a*x1 + b*x2');

subplot(3,1,2);
plot2d3(n,yt);
xlabel(' -------- > Time');
ylabel('-> Amplitude');
title('yt = a*y1 + b*y2');

subplot(3,1,3);
plot2d3(n,d);
xlabel(' -------- > Time');
ylabel('-> Amplitude');
title('difference of y and yt');

DEPT OF ECE 52
Basic Simulation Lab

OUTPUT:

RESULT:

hence the Linearity and time invariant properties of a given System is verified.

VIVA QUESTIONS:

1. Define linear system with example?


2. Define non- linear system with example?
3. Define super position principle?
4. Define time invariant system with example?
5. Define time variant system with example?

DEPT OF ECE 53
Basic Simulation Lab

Experiment -8
COMPUTATION OF UNIT SAMPLE, UNIT STEP AND SINUSOIDAL
RESPONSE OF THE GIVEN LTI SYSTEM AND VERIFYING ITS
PHYSICAL REALIZABILITY AND STABILITY PROPERTIES

AIM: Write a program to compute the Unit sample, unit step and sinusoidal response of the given
LTI system and verifying its stability

SOFTWARE REQUIRED: PC loaded with SCI LAB software

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);

DEPT OF ECE 54
Basic Simulation Lab

PROCEDURE:

1. Click on SCILAB Icon


2. Click on launch scinotes
3. Type the program on editor window
4. Save the program with filename.sce extension
5. Execute the program and observe the output/wave forms
PROGRAM:
// Impulse Response of an LTI system
clear all;
close all;
clc;

h = (-0.9).^[0:49];
subplot (2,2,1);
stem ([0:49],h,'filled');
xlabel('Samples');
ylabel('Amplitude');
title('h = (-0.9).^[0:49]');

u = ones(1);
subplot(2,2,2);
stem(u,'filled');
xlabel('Samples');

ylabel('Amplitude');
title('Impulse');

s = conv(u,h);

DEPT OF ECE 55
Basic Simulation Lab

subplot(2,2,[3,4]);
stem([0:49],s(1:50));

xlabel('Samples');
ylabel('Amplitude');
title('Response for an impulse');

// Step Response of an LTI system:


clear all;
close all;
clc;

h = (-0.9).^[0:49];
subplot (2,2,1);
stem([0:49],h,'filled');
xlabel('Samples');
ylabel('Amplitude');
title('h = (-0.9).^[0:49]');

u = ones(1,50);
subplot(2,2,2);
stem([1:50],u,'filled');
xlabel('Samples');
ylabel('Amplitude');
title('Step');

s = conv(u,h);
subplot(2,2,[3,4]);
stem([0:49],s(1:50));
xlabel('Samples');
ylabel('Amplitude');
title('Response for a step');

// Sinusoidal Response of an LTI System:


clear all;
close all;
clc;
t = 1:0.04:2;
h = (-0.9).^t;
subplot(2,2,1);
stem(t,h,'filled');
xlabel('Samples');
ylabel('Amplitude');
title('h = (-0.9).^t');

u = sin(2*pi*t);
DEPT OF ECE 56
Basic Simulation Lab

subplot(2,2,2);
stem(t,u,'filled');
xlabel('Samples');

ylabel('Amplitude');
title('Sine');

s = conv(u,h);
subplot(2,2,[3,4]);
stem([0:49],s(1:50));
xlabel('Samples');
ylabel('Amplitude');
title('Response for a sine');

// Stability of a given LTI System:


clear all;
close all;
clc;

n=0:0.1:20;
h= (0.5)*exp(-n);
sum=0;
for k=1:201
if abs(h(k))<10^(-6)

end

sum=sum+h(k);
end
stem(n,h);
disp('The summation value is ....:: ');sum
if sum > 5.0983e+008
disp('The System is unstable');
else
disp('The System is stable');
end;

DEPT OF ECE 57
Basic Simulation Lab

OUTPUT:

DEPT OF ECE 58
Basic Simulation Lab

The summation value is..... ::


DEPT OF ECE 59
Basic Simulation Lab

sum = 5.2542
The System is stable

RESULT:
The Unit sample, unit step and sinusoidal response of the given LTI system is computed and its
stability verified. Hence all the poles lie inside the unit circle, so system is stable.

VIVA QUESTIONS:

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


2. Define causality and stability?
3. Define step response and impulse response of the system.
4. Define poles and zeros of the system?
5. What is the function of filter?

DEPT OF ECE 60
Basic Simulation Lab

Experiment – 9

GIBBS PHENOMENON SIMULATION

AIM: Write a program to verify the Gibbs phenomenon.

SOFTWARE REQUIRED: PC loaded with SCILAB software

THEORY:

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

PROCEDURE:

1. Click on SCILAB Icon


2. Click on launch scinotes
3. Type the program on editor window
4. Save the program with filename.sce extension
5. Execute the program and observe the output/wave forms
PROGRAM:
clc;
J= 500 //number of points
x=linspace(0,2*%pi, J);
f= sign(x); //returns array same size as x
kp=0.*x; //multiplies everything by x starting with 0
t=150
for k=1:2:t
kp=kp+(1/2)*sin(k*x)/k;
end
plot(x,kp)

DEPT OF ECE 61
Basic Simulation Lab

output:

RESULT:

In this , Gibbs phenomenon have been demonstrated using SCILAB

VIVA QUESTIONS:

1. Define Gibb’s Phenomenon?


2. What is the importance of Gibb’s Phenomenon?
3. What is Static and Dynamic System?
4.Define Fourier series ?
5. What is Causality Condition of the Signal?

DEPT OF ECE 62
Basic Simulation Lab

Experiment -10

FINDING THE FOURIER TRANSFORM OF A GIVEN SIGNAL AND


PLOTTING ITS MAGNITUDE AND PHASE
SPECTRUM

AIM: Write a program to find the Fourier Transform of a given signal and plotting its magnitude
and phase spectrum.

SOFTWARE REQUIRED: PC loaded with SCILAB software

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 e2πinx/T in the Fourier series of ƒ is given By
definition Fourier Transform of signal f(t) and inverse fourier transform is defined as

PROCEDURE:

1. Click on SCILAB Icon


2. Click on launch scinotes
3. Type the program on editor window
4. Save the program with filename.sce extension
5. Execute the program and observe the output/wave forms

DEPT OF ECE 63
Basic Simulation Lab

PROGRAM:
clc ;
f=150 //(' enter the frequency in hertzs ');
Fs=2000 //('enter the samplinf freq in khz ')
Ts=1/(Fs);
N=128 //('enter the DFT sequence ');
n=[0:N-1]*Ts;
x=0.8*cos(2*%pi*f*n);
plot(n,x);
set(gca(),"grid",[1 1]);
data_bounds=([0 -1 ; 0.05 1]);
title(' cosine signal frequency ');
xlabel('time in n(sec) ');
ylabel(' amplitude');

Y=fft(x);
w=0:N-1;
figure;
Xmag=abs(Y);
subplot(2,1,1);
plot(w,Xmag);
set(gca(),"grid",[1 1]);
title(' magnitude of fourier transform ');
xlabel(' frequency index w ------ > ');
ylabel(' magnitude ----- > ');

Xphase= atan(imag(Y),real(Y));
subplot(2,1,2);
plot(w,Xphase);
set(gca(),"grid",[1 1]);
title(' phase of fourier transform ');
xlabel(' frequency index w ------ > ');
ylabel(' phase ----- > ');

DEPT OF ECE 64
Basic Simulation Lab

OUTPUT:

RESULT:
Magnitude and phase spectrum of fourier transform of a given signal is plotted.

DEPT OF ECE 65
Basic Simulation Lab

VIVA- VOCE QUESTIONS:

1. Define convolution property of Fourier transform?


2. What are the properties of Continuous-Time Fourier transform?
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?

DEPT OF ECE 66
Basic Simulation Lab

Experiment – 11

WAVEFORM SYNTHESIS USING LAPLACE TRANSFORMS

AIM: write a program to perform Wave form synthesis using Laplace Transforms
SOFTWARE REQUIRED: PC loaded with SCILAB Software
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 :

PROCEDURE:

1. Click on SCILAB Icon


2. Click on launch scinotes
3. Type the program on editor window
4. Save the program with filename.sce extension
5. Execute the program and observe the output/wave forms

PROGRAM:
clear all;
close all;
clc;
syms t w s
x=input ('Laplace Transform of a function .... :: ');
disp('is ...... :: ');
xf=laplace(x)

disp('Inverse Laplace Transform of a function ... :: ');

disp('is ...... :: ');

DEPT OF ECE 67
Basic Simulation Lab

xt=ilaplace(xf)

OUTPUT:
Laplace Transform of a function ....:: cos(w*t)
is ......::
xf = s/(s^2+w^2)
Inverse Laplace Transform of a function ....::
is ......::
xt =cos(w*t)

RESULT:

Hence performed the waveform synthesis using laplace transform

VIVA- VOCE 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?

DEPT OF ECE 68
Basic Simulation Lab

Experiment -12

LOCATING POLES AND ZEROS IN S-PLANE & Z-PLANE FOR THE


GIVEN TRANSFER FUNCTION

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.

SOFTWARE REQUIRED: PC loaded with SCILAB software

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
Ztransform is defined as

In signal processing, this definition is used when the signal is causal.

The roots of the equation P(z) = 0 correspond to the 'zeros' of X(z)


The roots of the equation Q(z) = 0 correspond to the 'poles' of X(z)
Example:

DEPT OF ECE 69
Basic Simulation Lab

PROGRAM:
clc;
clear all;
close all;

num = input('Enter the numerator coefficients.....:: ');


den = input('Enter the denominator coefficients.....:: ');

H = tf(num,den);
[p z]=pzmap(H);
disp('zeros at z= ');
disp(z);
disp('poles at p= ');
disp(p);

subplot(2,1,1);
pzmap(H);
title('pole zero map in s-domain ');

subplot(2,1,2);
zplane(num,den);
title('pole zero map in z-domain ');

OUTPUT:
Enter the numerator coefficients.....:: [1 0 -3]
Enter the denominator coefficients.....:: [1 -3 4]
zeros at z=
1.7321
-1.7321
poles at p=
1.5000 + 1.3229i
1.5000 - 1.3229i
DEPT OF ECE 70
Basic Simulation Lab

RESULT:

Pole-zero maps are plotted in s-plane and z-plane for the given transfer function

VIVA- VOCE QUESTIONS:

1. Study the details of pzmap() and zplane() 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. Define transfer function of the system?

DEPT OF ECE 71
Basic Simulation Lab

Experiment -13

GENERATION OF GAUSSIAN NOISE (REAL AND COMPLEX),


COMPUTATION OF IT’S MEAN, M.S.VALUEAND ITS
SKEW,KURTOSIS,AND PSD ,PROBABILITY DISTRIBUTION FUNCTION

AIM: Write the program for Generation of Gaussian noise (Real and Complex),
computation of its mean, M.S. value and its Skew, kurtosis, and PSD, probability
distribution function.

SOFTWARE REQUIRED: PC loaded with SCILAB software

THEORY:

Gaussian noise is statistical noise that has a probability density function (abbreviated pdf) of the
normal distribution (also known as Gaussian distribution). In other words, the values the noise
can take on are Gaussian-distributed. It is most commonly used as additive white noise to yield
additive white Gaussian noise (AWGN).Gaussian noise is properly defined as the noise with a
Gaussian amplitude distribution. says nothing of the correlation of the noise in time or of the
spectral density of the noise. Labeling Gaussian noise as 'white' describes the correlation of the
noise. It is necessary to use the term "white Gaussian noise" to be correct. Gaussian noise is
sometimes misunderstood to be white Gaussian noise, but this is not the case.

PROCEDURE:

1. Click on SCILAB Icon


2. Click on launch scinotes
3. Type the program on editor window
4. Save the program with filename.sce extension
5. Execute the program and observe the output/wave forms

.PROGRAM:
clc;
clear all;
close all;
N= input(' Enter the number of samples .... :: ');
DEPT OF ECE 72
Basic Simulation Lab

R1=randn(1,N);
M=mean(R1);
K=kurtosis (R1);

P=periodgram(R1);
V=var(R1);
x = psd(R1);

subplot(2,2,1);
plot(R1);
xlabel('Sample Number');
ylabel('Amplitude');
title('Normal [Gaussian] Distributed Random Signal');

subplot(2,2,2);
hist(R1);
xlabel('Sample Number');
ylabel('Total');
title('Histogram [Pdf] of a normal Random Signal');

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

OUTPUT:

DEPT OF ECE 73
Basic Simulation Lab

RESULT:

Hence Gaussian noise (Real and Complex) is generated and compute mean, M.S. value
and its Skew, kurtosis, and PSD, probability distribution function.

VIVA- VOCE QUESTIONS:

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


2. What is Gaussian noise?
3. What is correlation? How many types of correlation are there?
4. State Parseval’s energy theorem for a periodic signal?
5. What is Signum function?

DEPT OF ECE 74
Basic Simulation Lab

Experiment -14

SAMPLING THEOREM VERIFICATION

AIM: - Write a program to Verify the sampling theorem.

SOFTWARE REQUIRED: PC loaded with SCILAB software

THEORY:

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

Figure 1: Spectrum of band limited 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

PROCEDURE:

1. Click on SCILAB Icon


2. Click on launch scinotes
3. Type the program on editor window
4. Save the program with filename.sce extension
5. Execute the program and observe the output/wave forms

DEPT OF ECE 75
Basic Simulation Lab

PROGRAM:
clc;
clear all;
t=-5:.1:5;
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=-2:1:2;
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=-3:1:3;
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=-10:1:10;
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);
DEPT OF ECE 76
Basic Simulation Lab

plot(n3,x3)
grid;

OUTPUT:

RESULT:

Sampling theorem is verified.

VIVA-VOCE QUESTIONS:

1. State Parseval’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?

DEPT OF ECE 77
Basic Simulation Lab

Experiment -15

REMOVAL OF NOISE BY AUTO CORRELATION/CROSS


CORRELATION

AIM: Write the program for Removal of Noise by Auto Correlation/Cross Correlation.

SOFTWARE REQUIRED: PC loaded with SCILAB software

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

DEPT OF ECE 78
Basic Simulation Lab

periodic signal and n(t) is non periodic signal so Qss(T) is a periodic where as a Qnn(T) becomes
small for large values of T Therefore for sufficiently large values of T Qff(T) is equal to Qss(T).

PROCEDURE:

1. Click on SCILAB Icon


2. Click on launch scinotes
3. Type the program on editor window
4. Save the program with filename.sce extension
5. Execute the program and observe the output/wave forms

PROGRAM:
clear all;
close all;
clc;

t=0:0.1:pi*4;
s=sin(t);
k=2;
subplot(3,1,1);
plot(s);
xlabel('---> time');
ylabel('-> Amplitude');
title('Original signal');
n=rand(1,126);
f=s+n;
subplot(3,1,2);
plot(f);
xlabel('---> time');
ylabel('-> Amplitude');
title('Signal+noise');
as=xcorr(s,s);

subplot(3,1,3);
plot(as);
xlabel('---> time');
ylabel('-> Amplitude');
title('auto correlation s(t)');

DEPT OF ECE 79
Basic Simulation Lab

figure;
an=xcorr(n,n);
subplot(3,1,1)

plot(an);
xlabel('---> time');
ylabel('-> Amplitude');
title('auto correlation n(t)');
af=xcorr(f,f);
subplot(3,1,2)

plot(af);
xlabel('---> time');
ylabel('-> Amplitude');
title('auto correlation f(t)');
hh=as+an;
subplot(3,1,3)
plot(hh);
xlabel('---> time');
ylabel('-> Amplitude');
title('addition of s(t) and n(t)');

OUTPUT:

DEPT OF ECE 80
Basic Simulation Lab

RESULT:

Removal of noise using autocorrelation is performed.

VIVA-VOCE QUESTIONS:

1. Define Auto correlation function?


2. What are the Different types of noise signals?
3. Define cross correlation function?
4. What is Signum function?
5. What is Static and Dynamic System?

DEPT OF ECE 81
Basic Simulation Lab

Experiment -16

EXTRACTION OF PERIODIC SIGNAL MASKED BY NOISE USING


CORRELATION
AIM: write the program for Extraction of periodic signal masked by noise using correlation
SOFTWARE REQUIRED: PC loaded with SCILAB software

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.

PROCEDURE:

1. Click on SCILAB Icon


2. Click on launch scinotes
3. Type the program on editor window
4. Save the program with filename.sce extension
5. Execute the program and observe the output/wave forms

PROGRAM:
clear all;
close all;
clc;

N= input('Enter the number of samples ..... :: ');


M= input('Enter the number of cycles ..... :: ');

h=1/N;
x=0:h:M;
y=cos(3*pi*x);

subplot(4,1,1);
plot(x,y);
DEPT OF ECE 82
Basic Simulation Lab

xlabel('---> time');
ylabel('-> Amplitude');
title('Original signal');
w=rand(1,M*N+1);

subplot(4,1,2);
plot(x,w);
xlabel('---> time');
ylabel('-> Amplitude');
title('Noise');
k=y+w;

subplot(4,1,3);
plot(x,k);
xlabel('---> time');
ylabel('-> Amplitude');
title('Signal+noise');
m=xcorr(k);

subplot(4,1,4)
plot(x,0.01*m(1:M*N+1));
xlabel('---> time');
ylabel('-> Amplitude');
title('Recovered signal');

OUTPUT:

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


Enter the number of cycles .....:: 4

DEPT OF ECE 83
Basic Simulation Lab

RESULT:

Periodic signal is extracted by using correlation.

VIVA-VOCE QUESTIONS:

1. State the relationship between PSD and ACF?


2. What is the integration of ramp signal?
3. Difference between vectors and signals?
4. Define PSD?
5. Define Hilbert transforms?

Experiment -17

VERIFICATION OF WIENER-KHINCHIN RELATION

AIM: Write a program to Verify wiener-khinchin relation

SOFTWARE REQUIRED: PC loaded with SCILAB software

THEORY:

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

DEPT OF ECE 84
Basic Simulation Lab

PROCEDURE:

1. Click on SCILAB Icon


2. Click on launch scinotes
3. Type the program on editor window
4. Save the program with filename.sce extension
5. Execute the program and observe the output/wave forms

PROGRAM:
clc
clear all;
t=0:0.01:2*pi;
x=sin(2*t);

subplot(3,2,1);
plot(x);
au=xcorr(x,x);
Subplot (3,2,2);
plot (au);

v=fft(au);

subplot(3,2,3);
plot(abs(v));
fw=fft(x);

subplot(3,2,4);
plot(fw);
fw2=(abs(fw)).^2;
subplot(3,2,5);
plot(fw2);

OUTPUT:

DEPT OF ECE 85
Basic Simulation Lab

RESULT:

wiener-khinchin relation is verified.

VIVA-VOCE QUESTIONS:

1. What is mean wiener-khinchine relation?


2. Define fourier transform and its inverse?

DEPT OF ECE 86
Basic Simulation Lab

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?

Experiment -18

CHECKING A RANDOM PROCESS FOR STATIONARITY IN WIDE


SENSE

AIM: Write a program for Checking a Random Process for Stationary in Wide Sense

DEPT OF ECE 87
Basic Simulation Lab

SOFTWARE REQUIRED: PC loaded with SCILAB Software

THEORY:

The concept of stationarity plays an important role in solving practical problems involving
random processes. Just like time-invariance is an important characteristics of many deterministic
systems, stationarity describes certain time-invariant property of a class of random processes.
Stationarity also leads to frequency-domain description of a random process.

Strict-sense Stationary Process

A random process is called strict-sense stationary (SSS) if its probability structure is

invariant with time. In terms of the joint distribution function, is called SSS if

Thus, the joint distribution functions of any set of random variables does not
depend on the placement of the origin of the time axis. This requirement is a very strict. Less strict
form of stationarity may be defined.

PROCEDURE:

1. Click on SCILAB Icon


2. Click on launch scinotes
3. Type the program on editor window
DEPT OF ECE 88
Basic Simulation Lab

4. Save the program with filename.sce extension


5. Execute the program and observe the output/wave forms

PROGRAM:
clear all;
close all;
clc;
syms x
z = input('Enter the function ..... :: ');
Max = input('Max limit ....:: ');
Min = input('Min limit ....:: ');

mean_value = int(z,Min,Max)
y = subs(z,x,x+5);
Auto_correlation = int(z*y,Min,Max)

disp('If the mean value is constant .....');


disp('and');
disp('Auto Correlation is not a function of x variable ....');
disp('then ');
disp('The Random Process is Wide Sense stationary.');

OUTPUT:
Enter the function ..... :: 10*cos(10*x + 100)
Max limit ....:: 2*pi
Min limit ....:: 0
mean_value =0
Auto_correlation =100*cos(50)*pi

If the mean value is constant and Auto Correlation is not a function of x variable, then the
Random Process is Wide Sense stationary.

RESULT:

Hence checked the wide sense stationarity random process

DEPT OF ECE 89
Basic Simulation Lab

VIVA-VOCE QUESTIONS:

1. Define random process?


2. Give the types of random process?
3. Give the importance of random process?
4. Define strict-sense stationarity random process?
5. Define wide-sense stationarity random process?

DEPT OF ECE 90

You might also like