Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
231 views44 pages

Signal and Systems

lab manual for subject signal and systems

Uploaded by

sufiiiiyan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
231 views44 pages

Signal and Systems

lab manual for subject signal and systems

Uploaded by

sufiiiiyan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 44

Lab Manual

Signals and Systems


(EE 2511)

Revised By:
Arooj Unbreen

Revised On:
th
15 September, 2016

Department of Electrical Engineering


The University of Lahore, Lahore, Pakistan
1-KM Raiwind Road, Lahore.

1
Revision History

Revised Date Revised By Revised Topics

August 1,2016 Faraz Hasan Khan 1. The manual has been updated
according to HEC guidelines.
Lab # 14 & 15 which were
previously about Image Processing
are now replaced with sampling,
quantization and reconstruction of
band limited signals using
MATLAB.
September 5,2015 Saad Afzal 2. Fisrt two labs on MATLAB
introduction were revised.

January 10,2010 Abdul Rehman Yasin 3. Labs on signal addition and


multiplication were revised. Details
in Fourier Transform were added.

2
C E R T I F I CAT E O FAPPR O VAL

It is certified that the lab manual titled “Signals and Systems”, in scope and in quality, covers the
objectives and topics defined in the course outline.

Remarks by Mentor: -------------------------------------------------


Dr. Ishtiaq Ahmad
Assistant Professor
Department of Electrical Engineering
The University of Lahore

Remarks by HOD: -------------------------------------------------


Col Salamat Ullah
HOD
Department of Electrical Engineering
The University of Lahore

3
Table of contents

Lab 01: Introduction to MATLAB ………………………………………7

Lab 02: Introduction to even, odd and periodic signals.…………………16

Lab 03: Generation of Exponential and Random Signals.…………….19

Lab 04: Implementation of Unit Impulse and Unit Step Signals………21

Lab 05: Implementation of Addition and Multiplication of Signals…..23

Lab 06: Implementation of Shifting, Folding and Scaling of Signals….26

Lab 07: Open Ended Lab (Signals) …………………………………...…28

Lab 08: Signal Correlation ………………………………………………30

Lab 09: Signal Convolution………………………………………………32

Lab 10: Sampling and aliasing of the signal ………………………………34

Lab 11: Open Ended Lab (Periodic signals) ……………………………37

Lab 12: Stability………………………………………………..................38

Lab 13: Fourier Transform…………………………

Lab 14: Laplace Transform ..…

Lab 15: Open Ended Lab (Sampling of the signals)……………………37

Lab 16: Exam………………………

4
Signal and System Labs
Preface

This course deals with signals, systems, and transforms, from their theoretical mathematical foundations
to practical implementation in circuits and computer algorithms.
Whether analog or digital, information is represented by the fundamental quantity in electrical
engineering: the signal. Stated in mathematical terms, a signal is merely a function. Representation of
signals by sample values; discrete-time filter characterization and response; the z-transform; continuous-
time signals and linear, time-invariant systems; frequency response; continuous-time Fourier transform
and application to system analysis. MATLAB basics with application to signals and systems.
The manual presents and integrates the basic concepts for both continuous-time and discrete-time signals
and systems. Signal and system representations are developed for both time and frequency domains.
These representations are related through the Fourier transform and its generalizations, which are
explored in detail. Filtering and filter design, modulation, and sampling for both analog and digital
systems.
MATLAB is an environment for performing calculations and simulations of a variety of types. MATLAB,
short for matrix laboratory, was developed by Cleve Moler, a professor of mathematics and computer
science, in the late 70s and early 80s. In 1984, Cleve Moler and Jack Little founded The Math Works
which has been developing MATLAB ever since. In the earliest version of MATLAB, there were about 80
commands, and they allowed for matrix calculations. Now there are thousands of commands, and there
are many, many types of calculations that one can perform. Simulink is a MATLAB “add-on” that allows
one to simulate systems by combining blocks of various types. We will make use of Simulink as well.
During the course of this lab, the student will learn how to make calculations using MATLAB and will
learn a little about simulating systems using the simulation tools provided by MATLAB and Simulink.

Why Use MATLAB?

There are several goals for the development of a suite of effective demonstrations and applications for
teaching MSP. First, the concepts must be presented clearly with little interfering information. Second the
applications should be direct, flexible, and fast. Third, both sound and image must be used to demonstrate
concepts. Fourth, the demonstrations should leave plenty to explore. Fifth, a student should be able to
look into the code to understand how it works. Sixth, the demonstrations should be compatible with as
many computer platforms possible. And finally, the cost to students to be able to run the applications on
their own computer should be minimal.

There are a several low-level programming languages that can be used to demonstrate the application of
DSP, such as C++, and Java. But these require a high proficiency in programming, not to mention the
tangle of cross-platform issues. Sound processing languages Super Collider (McCartney 1996) or the
graphical programming applications Max/MSP or pd (Puckette 1996), can also be used to create
interesting demonstrations, but only for sound. Though these have excellent real-time capability, they
have marginal abilities for visual data display.

5
There are several high-level software packages that can be used to teach signal processing, such as
Mathematica, Octave, and MATLAB. A good overview of these and other packages in terms of
engineering education can be found in (Nagrial 2002). Mathematica is meant more for symbolic
mathematics than creating applications and it cannot easily produce sound. Octave, a free open-source
mathematics software application, is quite compatible with MATLAB code, but it lacks much of the rich
library of functions in MATLAB. In addition there is no easy way to create graphical user interfaces
(GUIs).

MATLAB provides a flexible integrated programming environment that is easy to use and understand,
and cheap for students. MATLAB is platform independent, has superior graphics handling and
visualization capabilities, and has a great GUI development environment for wrapping applications. In
addition it offers unparalleled functionality with many different data formats. It has an extensive library of
routines, and “toolboxes” can be purchased to add more specialized functionality, such as advanced signal
and image processing routines. Applications written in MATLAB are open; any user can look at the code.
Furthermore, countless institutions, both academic and corporate, as well as many independent users
worldwide, use MATLAB for algorithm development, quick prototyping, and complex problem solving.
A drawback to using MATLAB, however, is its lack of real-time functions, like tracking a sound as it
plays, or visualizing a spectrogram straight from the sound input. Though there should be some
familiarity with vectors and matrices, the MATLAB programming language is easy to learn and intuitive.
For these reasons it is clear that MATLAB is the best choice for developing applications that satisfy the
several criteria above.

6
Lab # 1
Title: Introduction to MATLAB
Name: Registration #
Section:

Objective:
 To introduce students to the Matlab environment and enable them to perform basic mathematical
operations.

Equipment:
 Computer system with installed MATLAB.

Pre-Lab:
 Installed software (MATLAB).

Introduction/Theory:

1. Introduction

The MATLAB® high-performance language for technical computing integrates computation,


visualization, and programming in an easy-to-use environment where problems and solutions are
expressed in familiar mathematical notation.

MATLAB is an interactive system which allows you to solve many technical computing problems. The
name MATLAB stands for matrix laboratory. MATLAB was originally written to provide easy access to
matrix software developed by the LINPACK and EISPACK projects. Today, MATLAB engines
incorporate the LAPACK and BLAS libraries, embedding the state of the art in software for matrix
computation.

2. The MATLAB System

The MATLAB system consists of these main parts:

2.1 Desktop Tools and Development Environment

This part of MATLAB is the set of tools and facilities that help you use and become more productive with
MATLAB functions and files. Many of these tools are graphical user interfaces. It includes: the MATLAB
desktop and Command Window, an editor and debugger, a code analyzer, and browsers for viewing help,
the workspace, and folders.

2.2 Mathematical Function Library

This library is a vast collection of computational algorithms ranging from elementary functions, like sum,
sine, cosine, and complex arithmetic, to more sophisticated functions like matrix inverse, matrix Eigen
values, Bessel functions, and fast Fourier transforms.

7
2.3 The Language

The MATLAB language is a high-level matrix/array language with control flow statements, functions,
data structures, input/output, and object-oriented programming features. It allows both “programming in
the small” to rapidly create quick programs you do not intend to reuse. You can also do “programming in
the large” to create complex application programs intended for reuse.

2.4 Graphics

MATLAB has extensive facilities for displaying vectors and matrices as graphs, as well as annotating
and printing these graphs. It includes high-level functions for two-dimensional and three-dimensional
data visualization, image processing, animation, and presentation graphics. It also includes low-level
functions that allow you to fully customize the appearance of graphics as well as to build complete
graphical user interfaces on your MATLAB applications.

2.5 External Interfaces

The external interfaces library allows you to write C and Fortran programs that interact with
MATLAB. It includes facilities for calling routines from MATLAB (dynamic linking), for calling
MATLAB as a computational engine, and for reading and writing MAT-files.

8
3. The MATLAB interface

Current Directory – Workspace –


Command Window – where your programs where variables
here commands are or M-files are saved are displayed
entered

Name -- Your folders and


Command History –
files in the current
your commands which
directory
you have entered in
near past

9
4. Basic operations in MATLAB

Operators

Expressions use familiar arithmetic operators and precedence rules.


+ Addition
- Subtraction
* Multiplication
/ Division
^ Power
' Complex conjugate transpose
.* Element-by-element multiplication
./ Element-by-element division
.^ Element-by-element power

Array:
The functional unit of data in any Matlab program is array. An Array is a collection of data values
organized into rows and columns and known by a single name.

Arrays can be classified as either vectors or matrices. The term VECTOR is usually used to describe an
array with only one dimension. While the term MATRIX is usually used to describe an array with two or
more dimensions. Following section will explain how we can declare any vector or signal in MATLAB.
Size of array is specified by the number of rows and the number of columns in the array, with the number
of rows mentioned first. The total number of elements in the array will be the product of the number of
rows and the number of columns.

Try using these values:

[3.4]
[1.0 2.0 3.0]
[1.0; 2.0; 3.0]
[1, 2, 3; 4, 5, 6]
[1, 2, 3, 4, 5, 6]
[]

Not all the elements of an array need to be defined when it is created. If a specific array element is
defined and one or more of the elements before it are not, then the earlier elements are automatically
created and initialized to zero. For example, if c is not previously defined, the statement

C(2,3)=5
Will produce matrix 0 0 0
005

Similarly the array d=[1 2]. Then the statement

d(4)=4

will produce d=[1 2 0 4].

Initializing with shortcut expressions


Matlab provides a special shortcut notation for these circumstances using the COLON operator. The colon
operator specifies a whole series of values by specifying the first vales in the series, the stepping
increment and then the last value in the series. The general form of a colon operator is
First: increment: last

For example
x=1:2:10
will generate x= 1 3 5 7 9
Try using angles=(0.01:0.01:1.00)*pi;

Transpose Operator(‘)

This operator swaps the rows and columns of any array that it is applied to.
For example try using:

And
F=[1:4]
F=[1:4]’
Initializing with Built-in Functions

Try using these:


A=zeros(2)
B=zeros(2,3)
C=[1 2; 3 4]
D=zeros(size(C))
E=ones(3)
E=ones(3,1)
E=eye(3)
E=eye(3,2)
Length(C).//Generate the longest dimension of the array.

Zeros can be used to create an all zero array of any desired size. If function has a single square array; it
will generate a square array using the single argument as both the number of rows and columns. size
function returns two values containing the number of rows and columns in an array.

Initializing variables with keyboard input

Input function displays a prompt string in the command window and then waits for the user to type in a
response. For example , consider the following statement:

My_val=input(‘enter an input value’);

Multi-dimensional Array
Matlab allows us to create arrays as many dimensions as necessary for any given problem. These arrays have
one subscript for each dimension and an individual element in the array will be the product of the maximum
value of each subscript. For example the following two statements create a 2X2X3 array C:

C(:,:,1)=[1 2 3; 4 5 6];
C(:,:,2)=[7 8 9; 10 11 12];

Sub Arrays
It is possible to select and use subsets of arrays as though they were separate arrays. To select a portion of
array, just include a list of all of the elements to be selected in the parenthesis after the rray name. For
example:
Arr1=[1.1 2.2 3.3 4.4 5.5]
Try using Arr1(3)
And Arr1([1 4])
And also Arr1(1:2:5)

End Function
It is very useful for creating array subscripts. When used in an array subscript; end returns the highest
value taken on by that subscript. For example. Suppose that array Arr3 is defined as follows:

Arr3=[ 1 2 3 4 5 6 7 8];

Then Arr3(5:end) would be the array [5 6 7 8] and Arr3(end) would generate 8.


The value returned by end is always the highest value of a given subscript. Is end appears in different
subscripts, it can return different values within the same expression. For example, suppose that the 3X4
array Arr4 is defined as follows:
Arr4=[1 2 3 4; 5 6 7 8; 9 10 11 12];

Then the expression


Arr4(2:end, 2:end)

would return the array. (Try this one).

Vectors
Following section will explain how we can declare any vector or signal in MATLAB.
 Simple Scalar

Scalars are numbers such as 1, 6, 9, 0 etc. To enter scalars in MATLAB the command will be
>>a = 4
 Row Vector:

Row vectors are those which have only one row such as [1, 2, 3, 8, 7]. To enter row vector in MATLAB
the command will be
>>a = [1, 2, 3, 8, 7] OR
> a= [1 2 3 8 7]

 Column Vector:

Column vectors are those which have only one column such as

To enter Column vector in 8 MATLAB the command will be


>>b = [1; 2; 8]

Matrix

Following
5 section will explain how we can declare matrix in MATLAB.

1 2 3
To enter matrix X= 4 5 6 in MATLAB the command will be
7 8 9

Note: If you want to multiple two signals then we have to use the .* operator. It will perform index by index
multiplication.

Getting help

To view the online documentation, select MATLAB Help from Help menu or MATLAB Help directly in the
Command Window. The preferred method is to use the Help Browser. The Help Browser can be started by
selecting the? Icon from the desktop toolbar. On the other hand, information about any command is available
by typing
> help <Command> or
> doc <Command>

Plot a function
The MATLAB environment provides a wide variety of techniques to display data graphically. Interactive
tools enable you to manipulate graphs to achieve results that reveal the most information about your data. We
can plot any function using MATLAB commands plot/ stem. Stem will create a discrete function. While plot
will generate a continuous function.

Executable Files:

The MATLAB software provides a full programming language that enables you to write a series of MATLAB
statements into a file and then execute them with a single command. MATLAB allows you to perform more
complex operations and it is easier to repeat these operations. For this purpose you will need to create the file.
The easiest way is to use the built in MATLAB editor. It will allow you to do some very simple
manipulations. When you write a MATLAB function or script, you save it to a file called an M-file.
Types of M-files:
There are two types of M-files that you can write:

Scripts:
 These are useful for automating a series of steps you need to perform many times.
 They do not accept input arguments and return output arguments.
 They store variables in a workspace internal to the function.

Functions:
 They are useful for extending the MATLAB language for your application.
 They can accept input arguments and return output arguments.
 They store variables in a workspace internal to the function.
To get MATLAB to execute the commands in the file simply type in the name of the file with which you
saved it. MATLAB will then search the current directory for the file and then it will read the file and
execute the commands in the file. MATLAB will show an error if you will type wrong file name.

Note: Do all exercises using script files.

Procedure:
 Read the manual thoroughly and write the commands in Matlab and see the results.

Observation and results:


 After writing the codes in matlab attach the results of that commands in your workbook.

Learning Outcomes

 Introduction of Matlab and its basic mathematical operations.


 Students will be able to understand the use of Variables and Arrays in MATLAB.

Questions
Exercise 1: Write the following commands in Matlab and attach the formulated outputs in
your workbook.
 a-b
 a*b
 a/b
 a^b
 a.-b
 a.*b
 a./b
 a.^b
 difference between a*b and a.*b?

Exercise 2: Construct the following Matrices using Matlab code.


 6x6 Matrix
 6x1 Matrix
 3x4 Matrix

Exercise 3: Develop the given matrix in Matlab and answer the following questions.

1.1 0.0 2.1 -3.5 6.0


0.0 1.1 -6.6 2.8 3.4
1.1 0.1 0.3 -0.4 1.3
-1.4 5.1 0.0 1.1 0.0

 Size of the array


 Value of the array(4,1)
 Size and value of array( : , 1 : 2 )
 array(3,:)
 array(:,3)
 array(1:2:3,[3 3 4])
 array([1 1],:)

Exercise 4: Create M-file using following commands which can calculate and plot the
following function sin(x) for 0≤x≤6, X=0:0.1:6;
Y=sin(X);
plot(X,Y);
Lab # 2
Title: Introduction to even, odd and periodic signals.

Name: Registration #
Section:

Objective:
 Learn sawtooth and square wave form in Matlab, and how to decompose a signal into even
and odd signals.

Equipment:
 Computer system with installed MATLAB.

Pre-Lab:
 Sound knowledge of even, odd periodic signals.

Introduction/Theory:
Periodic Signals
A sequence X [n] is said to be periodic when it satisfies the following relation

The fundamental period of the signal is defined as the smallest positive value of ‘N’ for which
above equation holds true. Now consider a signal Y [n] which is formed by the addition of the
two signals X1[n] and X2[n].

If the signal X1[n] is periodic with the fundamental period ‘N1’ and X2[n] is periodic with the
fundamental period ‘N2’ , then the signal y[n] will be periodic with the period ‘N’ given by the
following relation

Even and Odd decomposition

Any real sequence can be decomposed into two components that display even and odd symmetry about
the midpoint of the sequence. A sequence that exhibits even symmetry has its first and last samples equal,
its second and penultimate samples equal, and so on. A sequence that exhibits odd symmetry has its first
sample equal to the negative of the last sample, its second sample equal to the negative of its penultimate
sample, etc.
An even decomposition xe of a sequence x can be obtained as:

xe = 0.5*(x + fliplr(x));

and the corresponding odd decomposition xo is:


x0 = 0.5*(x - fliplr(x));

We can write a simple function that generates the even and odd components of an input sequence
x[n] as follows:

function [xe,xo] = evenOdd(x)


xe = (x + fliplr(x))/2;
xo = (x - fliplr(x))/2;

We can illustrate use of the above script with a simple example; assuming that x[n] = [1,3,5,7],we’ll
generate an even/odd decomposition and verify its correctness by summing the even and odd components,
and comparing to the original input signal x[n].

x = [1,3,5,7];
[xe,xo] = evenOdd(x);
re_comb = xe + xo
diff = x – re_comb

From the above we get xe = [4,4,4,4] and xo = [-3,-1,1,3], the sum of which is [1,3,5,7], i.e., the
original sequence x.

Another useful even/odd decomposition is defined such that

xe [n] = xe [-n]
and
xo[n] = -x o[-n]

In this case, the decompositions exhibit their symmetry about n = 0 rather than about the midpoint of the
original sequence x. For example, if x = [1,2,3,4] with corresponding sample indices n = [3,4,5,6], a
decomposition about n = 0 can be accomplished by padding x with zeros in such a manner to create a new
sequence with time indices symmetrical about zero. In this case, the new sequence is:

x = [zeros(1,9),1,2,3,4];
Procedure:
 Construct the given signals in Q1 and 2 in matlab using matlab code.
 Plot all the signals given in questions.
 Take the printout of these plots and attach theses in your workbook.

Observation and results:


 For Q#1 plot the signal between Amplitude (y-axis) and time (x-axis) and then attach the print of that
plot in your solution manual.
 For Q#2 plot the signal between Amplitude (y-axis) and time (x-axis) and then attach the print of that
plot in your solution manual.

Learning Outcomes
 To create even, odd and periodic signals.

Questions

Exercise 1: Develop a matlab code which can synthesize a square wave from its first five
harmonics and show the results to your instructor.

Exercise 2: Develop a matlab code which can generate even and odd parts of the signal, plot
the results. Generate the plot for x=0.9.^(0:1:30);for n=[0:1:30]
Lab # 3
Title: Generation of exponential and sinusoidal signals.

Name: Registration #
Section:

Objective:
 Learn how to generate exponential and sinusoidal signals in MATLAB.

Equipment:
 Computer system with installed MATLAB.

Pre-Lab:
 Sound knowledge of exponential and sinusoidal signals.

Introduction/Theory:
Exponential function:
An exponential function is a mathematical function of the following form:

where x is a variable, and a is a constant called the base of the function. The most commonly encountered
exponential-function base is the transcendental number e , which is equal to approximately 2.71828.
Thus, the above expression becomes:

When the exponent in this function increases by 1, the value of the function increases by a factor of e .
When the exponent decreases by 1, the value of the function decreases by this same factor (it is divided
by e )
There are three types of exponential functions i.e. Real exponentials complex exponential and imaginary
exponential.
Sinusoidal function:
A sinusoidal function (or sinusoidal oscillation or sinusoidal signal) is one that can be written in the form

The function f (t) is a cosine function which has been amplified by A, shifted by φ/ω, and compressed by
ω.
 A > 0 is its amplitude: how high the graph of f (t) rises above the t-axis at its maximum values.
 φ is its phase lag: the value of ωt for which the graph has its maximum (if φ = 0, the graph has the
position of cos(ωt); if φ = π/2, it has the position of sin(ωt)).
 τ = φ/ω is its time delay or time lag: how far along the t-axis the graph of cos(ωt) has been shifted
to make the graph of (1); (to see this, write

ω is its angular frequency: the number of complete oscillations f (t) makes in a time interval of
length 2π; that is, the number of radians per unit time.
 ν = ω/2π is the frequency of f (t): the number of complete oscillations the graph makes in a time
interval of length 1; that is, the number of cycles per unit time.
 P = 2π/ω = 1/ν is its period, the t-interval required for one complete oscillation.
One can also write (1) using the time lag τ = φ/ω
Procedure:
 Construct the given signals in Q1 to 3 in matlab using matlab code.
 Plot all the signals given in questions.
 Predict the stability of the system and write it in your solution manual in one or two lines.
 Take the printout of these plots and attach theses in your workbook.

Observation and results:


 For Q#1 plot the exponential signal between Amplitude (y-axis) and time (x-axis) and then attach
the print of that plot in your solution manual.
 For Q#2 plot the complex valued exponential signal between Amplitude (y-axis) and time (x-
axis) and then attach the print of that plot in your solution manual.
 For Q#3 plot the sinusoidal signal between Amplitude (y-axis) and time (x-axis) and then attach
the print of that plot in your solution manual.

Learning Outcomes

 To create exponential and sinusoidal signals.


 To predict the stability of the signals.

Questions

Exercise 1: Construct an exponential signal

(Hint: x=k*a^n use N=10, a=1, k=1)


Exercise 2: Construct a complex valued exponential signal

(Hint: use N=10, a=3, b=9 k=5)


Exercise 3: Construct a sinusoidal signal having the following specifications.
Fs=500e3, f=10e3, cycles=5.
Lab # 4
Title: Implementation of unit Impulse and unit step signals.

Name: Registration #
Section:

Objective:
 To implemented impulse (sample) and step function in MATLAB. Students will also learn
how to plot Unit impulse.

Equipment:
 Computer system with installed MATLAB.

Pre-Lab:
 Sound knowledge of unit impulse and unit step signals.

Introduction/Theory:
Signals are represented mathematically as functions of one or more independent variables. For
convenience, we generally refer to the independent variable as time. Signals are broadly classified into
analog and discrete signals.
An analog signal will be denoted by in which the variable represents time in seconds.

A discrete signal will be denoted by x(n) in which the variable is integer and represents discrete instances in
time. It is also represented as
x(n) = {x(n)} = {… . , x(−1), x(0), x(1), … } (1)

Where the up-arrow indicates the sample at n=0. In MATLAB we can represent a finite–duration
sequence by a row vector of appropriate values. However, such a vector doesn’t have any information
about sample position n. Therefore, a correct representation of x(n) would require two vectors, one each
for "x" and "n".
Unit Impulse Sequence:

The unit impulse signal is defined as

The response of this signal is shown in adjoining figure


Unit Step Sequence:
The unit step function is defined as and its response is also shown

Similarly, Sine & Cosine signals are also considered as basic signals.
0 ≠

Procedure:
 Construct the given signals in Q1 to 2 in matlab using matlab code.
 Plot all the signals given in questions.
 Take the printout of these plots and attach theses in your workbook.

Observation and results:


 For Q#1 plot unit impulse signal between Amplitude (y-axis) and n (x-axis) and then attach the
print of that plot in your solution manual.
 For Q#2 plot unit step signal between Amplitude (y-axis) and n (x-axis) and then attach the print
of that plot in your solution manual.

Learning Outcomes

 Implementation of basic sequences such as unit step and impulse signal in Matlab.

Questions

Exercise 1: Develop a code which can generate unit impulse signal having amplitude 1 and
range of n is from -5 to 5

Exercise 2: Develop a matlab code which can serve as an example for unit step signal.
Lab # 5
Title: Implementation of addition and multiplication of signals.

Name: Registration #
Section:

Objective:
 Addition and multiplication of signals with different sampling times in Matlab.

Equipment:
 Computer system with installed MATLAB.

Pre-Lab:
 Sound knowledge of signals.

Introduction/Theory:
Signal addition:
The first and foremost operation which we will consider will be addition. The addition of signals
is very similar to traditional mathematics. That is, if x1(t) and x2(t) are the two continuous time
signals, then the addition of these two signals is expressed as x1(t) + x2(t).
The resultant signal can be represented as y(t) from which we can write
y(t) = x1(t) + x2(t)
Similarly, for discrete time signals, x1[n] and x2[n], we can write
y[n] = x1[n] + x2[n]
Figure shows an example of addition operation performed over the continuous time signals x1(t)
and x2(t).
Signal Multiplication:
Two or more signals will be multiplied so as to obtain the new signal.
Mathematically, this can be given as:
y(t) = x1(t) × x2(t) … for continuous-time signals x1(t) and x2(t)
and
y[n] = x1[n] × x2[n] … for discrete-time signals x1[n] and x2[n]

Figure (c) shows the resultant discrete-time signal y[n] obtained by multiplying the two discrete-
time signals x1[n] and x2[n] shown in Figures 1(a) and 1(b), respectively.

Procedure:
 Construct the given signals in Q1 and 2 in matlab using matlab code.
 Plot all the signals given in questions.
 Take the printout of these plots and attach theses in your workbook.

Observation and results:


 For Q#1 plot the signal between x (y-axis) and n (x-axis) and then attach the print of that plot in
your solution manual.
 For Q#2 plot the signal between x (y-axis) and n (x-axis) and then attach the print of that plot in
your solution manual.
Learning Outcomes

 To create additive and multiplicative version of signals.

Questions

Exercise 1: Create the signal which is the addition of two continuous signals.

Exercise 2: Create the signal which is the multiplication of two continuous signals.
Lab # 6
Title: Implementation of shifting, folding and scaling of signals

Name: Registration #
Section:

Objective:
 To Implementation of shifting, folding and scaling of signals in MATLAB.

Equipment:
 Computer system with installed MATLAB.

Pre-Lab:
 Sound knowledge of definitions and formulas of shifting, folding and scaling of the signals.

Introduction/Theory:
Shifting:
In this operation each sample of x(n) is shifted by an amount to obtain a shifted sequence y(n).
y(n) = {x(n −k )}
If we let m= n−k, then n=m+k and the above operation is given by
y(m+k)={x(m )}
Hence this operation has no effect on the vector x, but the vector n is changed by adding k to each
element. This is shown in the function sigshift.
function [y,n] = sigshift(x,m,n0)
% implements y(n)=(n-n0)
% -------------------------
% [y,n] = sigshift(x,m,nO)
%
n =
m+n0
y = x
Folding:
In this operation each sample of x(n) is flipped around n = 0 to obtain a folded sequence y( ).
y(n) = {x(−n )}
In MATLAB this operation is implemented by fliplr(x) function for sample values and by -fliplr(n)
function for sample positions. Complete the following sigfold function.
function [y,n] = sigfold(x,n)
% implements y(n) = x(-n)
% -----------------------
% [y,n] = sigfold(x,n)
Scaling:
In this operation each sample is multiplied by a scalar a.
{x(n)} = x(an)
An arithmetic operator ".*" is used to implement the scaling operation in MATLAB.
0 ≠

Procedure:
 Construct the given signals in Q1 to 3 in matlab using matlab code.
 Plot all the signals given in questions.
 Take the printout of these plots and attach theses in your workbook.
Observation and results:
 For Q#1 plot unit impulse signal between Amplitude (y-axis) and n (x-axis) and then attach the
print of that plot in your solution manual.
 For Q#2 plot unit step signal between Amplitude (y-axis) and n (x-axis) and then attach the print
of that plot in your solution manual.
 For Q#3 plot unit step signal between Amplitude (y-axis) and n (x-axis) and then attach the print
of that plot in your solution manual.
Learning Outcomes

 Implementation of shifting, folding and scaling of signals in Matlab.

Questions

Exercise 1: Develop a matlab code which can serve as an example for shifting of the
original signal.

Exercise 2: Develop a matlab code which can serve as an example for folded version of the
original signal.

Exercise 3: Develop a matlab code which can serve as an example for scaled version of the
original signal.
Lab# 7
Title: Open ended lab

Name: Registration #
Section:

Objective:
 To Design a system with given input and desired output signals.

Input signal

Desired output

Equipment:
 Breadboard, Connecting wires, Resistors, Oscilloscope.

Pre-Lab:
 Sound knowledge about signals.

Introduction/Theory:
In communication systems, signal processing, and electrical engineering, a signal is a function that
"conveys information about the behavior or attributes of some phenomenon". A signal may also be
defined as an "observable change in a quantifiable entity". In the physical world, any quantity
exhibiting variation in time or variation in space (such as an image) is potentially a signal that might
provide information on the status of a physical system, or convey a message between observers,
among other possibilities
0 ≠

Procedure:
 Perform the above task on hardware.

Observation and results:


 Take the picture of your hardware and attach it in your workbook.
 Also draw the circuit diagram in your workbook.

Learning Outcomes

 Generation of signals using lab apparatus.

Lab # 8
Title: Signal Correlation.

Name: Registration #
Section:

Objective:
 To become familiar with the correlation coefficients.

Equipment:
 Computer system with installed MATLAB.

Pre-Lab:
 Sound knowledge of correlation of the signals.

Introduction/Theory:
. Correlation is an important concept that is used to determine the degree of similarity between two
signals. The value of correlation coefficient lies between -1 to 1.
−1< 𝑝 <1
Formula:
If we have two signals (�) 𝑎𝑛� (�) and we want to find the similarity between these two signals.
Correlation coefficient determines the degree of similarity in between them. Formula is given in equation
5-0-1.

0 ≠

Procedure:
 Construct the given signals in Q1 to 2 in matlab using matlab code.
 Plot all the signals given in questions.
 Take the printout of these plots and attach theses in your workbook.

Observation and results:


 For Q#1 plot unit impulse signal between Amplitude (y-axis) and n (x-axis) and then attach the print
of that plot in your solution manual.
 For Q#2 plot unit step signal between Amplitude (y-axis) and n (x-axis) and then attach the print of
that plot in your solution manual.

Learning Outcomes

 Implementation of correlation of signals in Matlab.

Questions
Exercise 1:
Two signals are provided. Develop the matlab code for finding the correlation on the two
signals and plot the output.

N 0 1 2 3 4 5 6 7 8
x1(n) -4 1 3 7 4 -2 -8 -2 -1
x2(n) 4 2 -1 3 -2 -6 -5 4 5

Exercise 2:
Develop the matlab code for finding the auto-correlation of the signal and plot the output.

N 0 1 2 3 4 5 6 7 8
x1(n) -4 1 3 7 4 -2 -8 -2 -1
Lab # 9
Title: Signal Convolution

Name: Registration #
Section:

Objective:
 To Learn how to find convolution of discrete and continuous time signals

Equipment:
 Computer system with installed MATLAB.

Pre-Lab:
 Sound knowledge of convolution of the signals.

Introduction/Theory:
Convolution:
A linear time invariant (LTI) system is completely characterized by its impulse response h[n]. “We
can compute the output y[n] due to any input x[n] if know the impulse response of that system”. We
say that y[n] is the convolution of x[n] with h[n] and represent this by notation

The operation of the discrete time convolution takes two sequences x[n] and h[n] and produces a
third sequence y[n]. Above equation expresses each sample of the output sequence in terms of all the
samples of the input and the impulse response sequences.
Convolution Implementation in MATLAB:
In MATLBA “CONV” function is used for “convolution and polynomial multiplication”.
y=conv(x,h) convolves vectors x and h. The resulting vector ‘y’ is of “length(A)+length(B)-1”.
If ‘x’ and ‘h’ are vectors of polynomial coefficients, convolving them is equivalent to multiplying
the two polynomials
Suppose we want to convolve the 2 signals x[n] and h[n] shown in the figure below. We will write
their values and then use the MATLAB command “conv” to convolve the signals and get the result
of convolution y[n] between x[n] and h[n].
The coding for performing the Discrete time convolution between the signal x[n] and its impulse
response h[n] and getting the desired convolved signal y[n] is given below:
Syntax
w = conv(u,v) ≠

Procedure:
 Construct the given signals in Q1 to 2 in matlab using matlab code.
 Plot all the signals given in questions.
 Take the printout of these plots and attach theses in your workbook.
Observation and results:
 For Q#1 plot unit impulse signal between Amplitude (y-axis) and time (x-axis) and then attach the
print of that plot in your solution manual.
 For Q#2 plot unit step signal between Amplitude (y-axis) and time (x-axis) and then attach the print
of that plot in your solution manual.

Learning Outcomes
 To convolute signals in Matlab.

Questions

Exercise 1: Develop the matlab code which can perform the convolution y(n) of the two signals
mathematically and then by using the
following MATLAB command
>>y =conv(x,h)
Let ;
x(n)= [3,11,7,0¬,-1,4,2] -3≤n≤3;
h(n)= [2,3¬,0,-5,2,1] -1≤¬n≤4
find y[n] using the above command.

Exercise 2:
Develop the matlab code which can perform the convolution y(n) of the two signals
mathematically and then by using the
following MATLAB command
>>y =conv(x,h)
Let ;
xn=[0 0 0 1 0 4/3 0 0 -1 0 0];
hn=[0 0 0 0 0 1 2/3 1/3 0 0 0];
find y[n] using the above command.
Lab # 10
Title: Sampling and aliasing of the signal.

Name: Registration #
Section:

Objective:
 To learn how to sample the signals.
 To get the concept of aliasing of the signal.

Equipment:
 Computer system with installed MATLAB.

Pre-Lab:
 Sound knowledge of sampling theorm.

Introduction/Theory:
The Sampling Theorm:
“A continuous time signal X[t] with frequencies no higher than Fmax can be
reconstructed exactly from its samples X[n] = X(nTs), if the samples are taken at a rate Fs = that is
greater than 2Fmax”.
Fs ≥ 2Fmax
The minimum sampling rate of 2Fmax is called the Nyquist Rate. From sampling theorem it follows
that the reconstruction of a signal is possible if we have at least 2 samples per period. If we don’t
sample at a rate that satisfies the sampling theorem then aliasing occurs.
Concept of aliasing:
Consider the general formula for a discrete time sinusoid X = Cos(wπn+Ф ). Now consider X1 =
Cos (0.1πn), X2 = Cos (2.1πn) & X3 = Cos (1.9πn) apparently with different values of w. If we
display the graph of these 3 signals over the range n = 0:40 then we see that all the above signals are
equivalent.
Therefore the signals X1, X2 & X3 are different names for the same signal. This phenomenon is
called aliasing. The signals X2 & X3 are called aliases of the signal X1. Coding for plotting the
above signals is shown below ≠

Procedure:
 Construct the given signals in Q1 to 2 in matlab using matlab code.
 Plot all the signals given in questions.
 Take the printout of these plots and attach theses in your workbook.
 Write the answers of Q3 in your workbook.

Observation and results:


 For Q#1 plot unit impulse signal between Amplitude (y-axis) and time (x-axis) and then attach the
print of that plot in your solution manual.
 For Q#2 plot unit step signal between Amplitude (y-axis) and time (x-axis) and then attach the print
of that plot in your solution manual.

Learning Outcomes
 To learn basics of sampling and aliasing of the signals in Matlab.

Questions
Example 1: Consider the signal
Y[n] = X1[n] + X2[n]
X1[n] = cos(n/12) X2[n] = cos(n/18)
Determine the value of N2 & plot the signal X2[n] over the range n = 0:2N2. Verify from the
composed graph that there are 2 complete cycles of the signal X2[n].

Example 2: Consider a signal X 1 = cos ( 0.25 π n ) over the range n=0:40 .What will be the
aliases of the signal X1. Develop the plot of X1 signal and its 2 aliases all in the same window
using “subplot” command. Observe graphically that all the aliases of X1 have the same graph.
Actually a signal can have infinite number of aliases.

Example 3:
With increasing sampling frequency fs, the mean square error of the reconstructed
output w.r.t the original signal

increases.
remains uneffected.
almost zero.
remains constant after initial decrease.

The main cause of aliasing distortion observed in frequency domain in sampling of a continuous time
signal is
the signal spectra being band-limited.
the signal spectra being non band-limited.
sampling in time domain.

Linear interpolation based reconstruction process


maintains the value of the previous sampling instant till next sampling instant.
joins the adjacent sampling points by a straight line.
joins the adjacent sampling points by a second-order polynomial.

What is over sampling?


Sampling a signal with sampling frequency significantly higher than the bandwidth of the signal
being sampled.
Sampling a signal with sampling frequency significantly lower than the bandwidth of the signal
being sampled.
Sampling a signal with sampling frequency significantly higher than twice the bandwidth of the
signal being sampled.
Sampling a signal with sampling frequency three times higher than the bandwidth of the signal being
sampled.
What do you mean by under sampling ?
Sampling the signal at Nyquist rate.
Sampling the signal below the Nyquist rate.
Sampling the signal greater than or equal to Nyquist rate.

What is the use of anti-aliasing filter?


It is used for reconstruction of a signal.
It is used to restrict the bandwidth of a signal to satisfy the sampling theorem and to prevent
aliasing.

A signal can be reconstructed from its samples by using which method?


Filtering.
Resampling.
Auto-correlation.

Lab# 11
Title: Open ended lab

Name: Registration #
Section:

Objective:
 To design a system which can add odd harmonics of 10kHz sine wave with the following
proportion.
First harmonic 100%
3rd harmonic (1/3) %

Equipment:
 Breadboard, Connecting wires, Resistors, Oscilloscope, op-amp.

Pre-Lab:
 Sound knowledge about even, odd and periodic signals.

Introduction/Theory:
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.

Periodic signal: 0 ≠

A signal is a periodic signal if it completes a pattern within a measurable time frame, called a period
and repeats that pattern over identical subsequent periods. The completion of a full pattern is called a
cycle.

Procedure:
 Perform the above task on hardware.

Observation and results:


 Take the picture of your hardware and attach it in your workbook.
 Also draw the circuit diagram in your workbook.

Learning Outcomes

 Generation of signals using lab apparatus.

Lab # 12
Title: Stability

Name: Registration #
Section:

Objective:

Equipment:
 Computer system with installed MATLAB.

Pre-Lab:

Introduction/Theory: ≠

Procedure:

Observation and results:

Learning Outcomes

Questions

Exercise 1:

Exercise 2:

Lab # 13
Title: Fourier Transform.
Name: Registration #
Section:

Objective:
 To observe discrete time and continuous time Fourier Transform of signals in Matlab.

Equipment:
 Computer system with installed MATLAB.

Pre-Lab:
 Sound knowledge of Fourier Transform.

Introduction/Theory:
Continuous Fourier Transform:
We can then extend the ideas of frequency decomposition to non-periodic signals via the Fourier
Transform. A Fourier transform can be used to analyze a circuit in the frequency domain much like
the Laplace transform can be used to analyze circuits in the s domain. The Fourier transform is
defined by

MATLAB uses the fourier and ifourier functions to transform expressions between domains. Write
the following commands in MATLAB and understand them.
>>help fourier
>>help ifourier
Discrete Fourier Transform:
If �(𝑛) is absolutely sum able, that is

, then its discrete-time Fourier transform is given by

The DTFT transforms a discrete signal �(𝑛) into a complex-valued continuous function �( ) of
real variable �, called a digital frequency, which is measured in radians.

Procedure:
 Construct the given signals in Q1 to 4 in matlab using matlab code.
 Plot all the signals given in questions.
 Take the printout of these plots and attach theses in your workbook.

Observation and results:


 For Q#1 plot unit impulse signal between Amplitude (y-axis) and time (x-axis) and then attach the
print of that plot in your solution manual.
 For Q#2 plot unit step signal between Amplitude (y-axis) and time (x-axis) and then attach the print
of that plot in your solution manual.
 For Q#3 plot unit step signal between Amplitude (y-axis) and time (x-axis) and then attach the print
of that plot in your solution manual.
 For Q#4 plot unit step signal between Amplitude (y-axis) and time (x-axis) and then attach the print
of that plot in your solution manual.

Learning Outcomes
 To learn the relationship between the time and frequency domains as shown by performing
the fourier analysis of assigned signals.

Questions

Exercise 1: Develop the Matlab code for finding the fourier transform of the signal

Exercise 2: Develop the matlab code for the Fourier and its inverse transforms of

Exercise 3: Develop the matlab code for the Fourier and its inverse transforms of

Exercise 4: Develop the matlab code for the Fourier and its inverse transforms of

Lab # 14
Title: Laplace Transform.
Name: Registration #
Section:

Objective:
 To Learn how to find convolution of discrete and continuous time signals

Equipment:
 Computer system with installed MATLAB.

Pre-Lab:
 Sound knowledge of convolution of the signals.

Introduction/Theory: ≠

Procedure:
 Construct the given signals in Q1 to 2 in matlab using matlab code.
 Plot all the signals given in questions.
 Take the printout of these plots and attach theses in your workbook.

Observation and results:


 For Q#1 plot unit impulse signal between Amplitude (y-axis) and time (x-axis) and then attach the
print of that plot in your solution manual.
 For Q#2 plot unit step signal between Amplitude (y-axis) and time (x-axis) and then attach the print
of that plot in your solution manual.

Learning Outcomes
 To convolute signals in Matlab.

Questions

Exercise 1:

Exercise 2:

Lab# 15
Open ended lab
Name: Registration #
Section:

Objective:
 Generate the audio signals at different rates and then listen them and check the effect of change
in frequency of the audio signal.

Equipment:
 Breadboard, Connecting wires, Resistors, Oscilloscope, op-amp.

Pre-Lab:
 Sound knowledge about sampling.

Introduction/Theory:
Sampling:
A signal is referred to as an even if it is identical to its time-reversed counterparts; x(t) = x(-t).

Procedure:
 Perform the above task on hardware.

Observation and results:


 Take the picture of your hardware and attach it in your workbook.
 Also draw the circuit diagram in your workbook.

Learning Outcomes

 Sampling of the audio signals using lab apparatus.


 Effect of the change in frequency of the signal

Lab# 16
Exam.
Name: Registration #
Section:

Teacher will conduct the exam in this lab.

You might also like