Académique Documents
Professionnel Documents
Culture Documents
School of Engineering
1
Signals And Systems Lab Manual EL-315
Asma Umar
Lab Engineer
SaimaShaheen
Lab Engineer
School of Engineering
University of Management and Technology
CII, Johar Town Lahore
http:/www.umt.edu.pk
2
Signals And Systems Lab Manual EL-315
1 Introduction to MATLAB
3
Signals And Systems Lab Manual EL-315
Text Book: Signals & Systems by Simon Haykin and Barry Van Veen, 2 nd
Edition, John Wiley & Sons
4
Signals And Systems Lab Manual EL-315
Roll #:_____________________________
OBJECTIVES:
MATLAB is a programming language and data visualization software package which is especially
effective in signal processing and system analysis.
If you know the name of a function which you would like to learn how to use, use the help.
>> help function name
This command displays a description of the function and generally also includes a list of
related Functions. If you cannot remember the name of the function, use the lookfor.
>>lookfor keyword
This command will display a list of functions that include the keyword in their
descriptions.
Other help commands that you may find useful are info what and which.
MATLAB stores variables in the form of matrices which are M x N, where M is the number of
rows and N is the number of columns. All elements of a matrix can be real or complex numbers.
5
Signals And Systems Lab Manual EL-315
Arithmetic Operations
There are also three other operators that operate on an element by element basis:
.* multiplication of two vectors, element by element
./ division of two vectors, element-wise
.^ raise all the elements of a vector to a power.
Example:-
>> X= [1,3,4]
>> Y= [4,5,6]
>> X+Y
Ans= __________
>> X*Y.
Ans= __________
>> X.*Y
Ans = ___________
Complex numbers :
MATLAB also supports complex numbers. The imaginary number is denoted with the i. or j..
>> z =3 + 4i
>>conj(z) =______________ % computes the conjugate of z
>>angle(z) =______________ % computes the phase of z
>>real(z) = ______________ % computes the real part of z
>>imag(z) = ______________ % computes the imaginary part of z
>>abs(z) = ______________ % computes the magnitude of z
Array Indexing
In MATLAB, all arrays (vectors) are indexed starting with 1, i.e., y(1) is the first element of the
array y. Note that the arrays are indexed using parenthesis (.) and not square brackets[.] as in
C/C++. To create an array having as elements the integers 1 through 6, just enter:
6
Signals And Systems Lab Manual EL-315
>> x=[1,2,3,4,5,6]
The: notation above creates a vector starting from 1 to 6, in steps of 1. If you want to create a
vector from
1 to 6 in steps of say 2, then type:
Extracting or inserting numbers in a vector can be done very easily. To concatenate an array, you
can usethe []operator, as shown in the example below:
>> x=[1:3 4 6 100:110]
Allocating memory
You can allocate memory for one-dimensional arrays (vectors) using the zeros command.
The following command allocates memory for a 100-dimensional array:
>> Y = zeros(100,1);
>>Y(30) = ______________
Similarly, you can allocate memory for two-dimensional arrays (matrices). The command >>
Y=zeros (4, 5) defines a 4 by 5matrix.
>> Y= ones (1, 5) = ____________________________________
7
Signals And Systems Lab Manual EL-315
; Indicates the end of a row in a matrix. It is also used to suppress printing on the screen
% denotes a comment. Anything to the right of % is ignored by the MATLAB interpreter and is
considered as comments
. Denotes transpose of a vector or matrix. It is also used to define strings,
e.g., str1=’DSP’;
Control Flow
The if, for, switch and while statements need to terminate with an end statement.
Examples:
IF:
>> X = -3;
>> If X>0 str =’positive.’
elseif X==0 str = ‘equal. ‘
elseif X <0 str = ‘negative.’
else str= ‘error.’
end
Answer :-str = _______________________________
Do if X = 3
Answer :-str = _______________________________
8
Signals And Systems Lab Manual EL-315
WHILE:
>> X= -10 ;
>>while X < 0
X= X+1;
end
FOR loop:
>> Y= 0;
for X= 1:10
Y=Y+1;
end
Value of X after execution of loop =_________________________________
BREAK:
The break statement lets you exit early from a for or a while loop:
>> x=-10;
while x<0
x=x+2;
if x == -2
break;
end
end
Relational Operators
Symbol Meaning:
<= Lessthanequal
< Less than
>= Greater than equal
> Greater than
== Equal
~=Not equal
Logical Operators
Symbol Meaning:
& AND
| O
~ NOT
9
Signals And Systems Lab Manual EL-315
Math Functions
MATLAB comes with a large number of built-in functions that operate on matrices on an
element-by element basis. These include:
sin sine
cos cosine
tan tangent
exp exponential
lognatural logarithm
log10 common logarithm
sqrt square root
absabsolute value
Plotting
10
Signals And Systems Lab Manual EL-315
MATLAB programming is done using M-files, i.e., files that have the extension .m. These files are
created using
a text editor. To open the text editor, go to the File pull-down menu, choose New, then M-file.
After you type in the program, save it, and then call it from the command window to execute it.
Example:-
Say for instance that you want to write a program to compute the average (mean) of a vector x.
The program should take as input the vector x and return the average of the vector.
Steps:
1. You need to create a new file, called “average.m”. Open the open the text editor by going to
the File pull-down menu; choose New, then M-file. Type the following in empty text file.
function y=average(x)
L=length(x);
sum=0;
for i=1:L
sum=sum+x(i);
end
y=sum/L; % the average of x
Remarks:
y is the output of the function “average”
Average is the name of the function. It is best if it has the same name as the filename. MATLAB
files always need to have the extension .m2. From the Editor pull-down menu, go to File | Save,
and enter: average.m for the filename.
>> x=1:100;
>> y=average(x)
ans =
50.5000
11
Signals And Systems Lab Manual EL-315
LAB Assignment
Write a MATLAB program that will add all the numbers corresponding to the even or odd (your
registration number) indices of an array. For instance, if the array x was x=[1, 3, 5, 10], and your
registration number is even ;
then it should return 13 (= 3 + 10). Use that program to find the sum of all integers from 1 to your
Registration number. Write your program so that it is flexible. That is, you should be able to
invoke your program from
the command window as follows:
>> y = addnumber(x)
Where x is the input vector, and y is the sum of all the numbers corresponding to the indices of x.
12
Signals And Systems Lab Manual EL-315
Observations/Comments/Explanation of Results:
13
Signals And Systems Lab Manual EL-315
Questions:
14
Signals And Systems Lab Manual EL-315
OBJECTIVES:
INTRODUCTION
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𝑥(𝑛)in which the variable 𝑛is integer and represents
discrete instances in time. It is also represented as
BASIC SEQUENCES
𝟏, 𝒏=𝟎 (2-2)
𝜹[𝒏] = {
𝟎, 𝒏≠𝟎
15
Signals And Systems Lab Manual EL-315
We will see how we can use unit impulse (sample) signal as basic building blocks for the
construction and representation of other signals.
δ(n) 1
n
Figure2-1: Discrete-Unit sample (impulse)
Similarly unit sample can be expressed as the first difference of the unit step.
Unit Impulse can be used to sample the value of the signal at n=0.
𝟏, 𝒏≥𝟎 (2-5)
𝒖[𝒏] = {
𝟎, 𝒏<0
16
Signals And Systems Lab Manual EL-315
1
u (n)
.......
.
0 1 2 3 4 . . . n
There is a close relationship between the unit step and unit sample i.e. unit step is the running
sum of the unit sample.
+∝
+𝑵
𝟏
𝑷 ∝ = 𝐥𝐢𝐦 ∑|𝒙[𝒏]|𝟐 − 𝑵 ≤ 𝒏 ≤ +𝑵 (2-8)
𝑵→∝ 𝟐𝑵 + 𝟏
−𝑵
16
Signals And Systems Lab Manual EL-315
LAB TASK
Note: make m-file, show function’s plot,xlabel,ylabel,hold, stem and observe the output and show to
the instructor, see MATLAB help.
function [x,n]=impseq(n0,n1,n2)
%Generate x(n) = delta(n-n0); n1 ≤n≤n2
%---------------------------------------------------
%[x,n]=impseq(n0,n1,n2)
n=[n1:n2]; x= [(n-n0)== 0];
Where the superscript “*” denotes the operation of complex conjugation. The energy of a finite
duration sequence x(n) can be computed in MATLAB using
SIGNAL POWER:
17
Signals And Systems Lab Manual EL-315
LAB ASSIGNMENT
Give a title to the graph, label the x-axis and the y-axis respectively. Give specific color lines to
the input and output for discrimination.(Hint see MATLAB “help plot”)
P.1
Generate and plot the samples of the following sequences using MATLAB. Also find energy
and power of these functions.
a. 𝑥1 (𝑛) = ∑10
𝑚=0(𝑚 + 1)[𝛿(𝑛 − 2𝑚) − 𝛿(𝑛 − 2𝑚 − 1)], 0 ≤ 𝑛 ≤ 25
25 ≤ 𝑛 ≤ 25
Hint: See Matlab help for “stem” function and “for loop”
18
Signals And Systems Lab Manual EL-315
Observations/Comments/Explanation of Results:
19
Signals And Systems Lab Manual EL-315
Questions:
20
Signals And Systems Lab Manual EL-315
OBJECTIVES:
TYPES OF SEQUENCES
Where “𝐶“ and “𝑎” are real . There are basically two types of behavior.
If a is positive
As “n” increases “𝑥[𝑛]” is growing exponential, a form that describes different physical
processes including chain reactions and complex chemical reactions.
If a is negative
As “n” increases “𝑥[𝑛]” is decaying exponential, a form that describes the radioactive
decay, RC circuits and damped mechanical systems.
SINUSOIDAL SIGNALS
Sinusoidal signal is defined as:
21
Signals And Systems Lab Manual EL-315
RANDOM SINGALS
Many practical signals can’t be described by mathematical expressions like those
explained above. Such sequences are called the random (or stochastic) sequences and
characterized by probability density function or statistical moments.
PERIODIC SEQUENCE
A sequence x[n] is periodic if
The smallest integer that satisfies the above relation is called the fundamental period.
22
Signals And Systems Lab Manual EL-315
LAB TASK
𝑥1[𝑛] = (0.9)𝑛1 ; 0 ≤ 𝑛1 ≤ 10
n1 = [0:10];
x1 = (0.9).^n1;
Plot “ x1(n1)”.
Label x-axis and y-axis.
Also give title to the graph.
clc;
c = -(1/12)+(pi/6)*i;
K = 2;
n = 0:40;
22
Signals And Systems Lab Manual EL-315
x = K*exp(c*n);
subplot(2,1,1);
stem(n,real(x));
title(’Real part’);
subplot(2,1,2);
stem(n,imag(x));
title(‘Imaginary part’);
clc;
x = K*a.^+n;
stem(n,x);
n = [0:40];
x1 = rand(1,41);
stem(n,x1)
Plot “ x1(n1)”.
Label x-axis and y-axis.
Also give title to the graph.
23
Signals And Systems Lab Manual EL-315
LAB ASSIGNMENT
P.1
Generate a random sequence of numbers upto 40 numbers of samples , called x1, then multiply
it with sin(n), and plot the result.
P.2
𝒙(𝒏) = 𝒔𝒊𝒏(𝒏)𝒆(−𝟒𝝅𝒏) , 𝟎 ≤ 𝒏 ≤ 𝟏𝟎
24
Signals And Systems Lab Manual EL-315
Observations/Comments/Explanation of Results:
25
Signals And Systems Lab Manual EL-315
Questions:
26
Signals And Systems Lab Manual EL-315
OBJECTIVES:
BASIC OPERATIONS
TIME SHIFT
TIME REVERSAL
𝒙[−𝒏] (4-2)
A Time reversal signal x[−n] of x[n]is obtained by reflection about n=0 (i.e by reversing
the signal).
TIME SCALING
𝒙[𝜶𝒏] (4-3)
If we represent three signals x[n] , x[2n], x[3n] , that are related by linear scale changes
in the independent variable. If we think of the example x[n] as tape recording, then
27
Signals And Systems Lab Manual EL-315
x[2n] is that recording played at twice the speed, and x[n/2] is the recording played at
half-speed.
PERIODIC SEQUENCE
A sequence x[n] is periodic if
The smallest integer that satisfies the above relation is called the fundamental period.
28
Signals And Systems Lab Manual EL-315
LAB TASK
Signal addition is implemented in MATLAB by using the arithmetic operator “+”. However, the
length of x1(n) and x2(n) must be same. If sequences are of unequal length, or if the sample
positions are different for equal length sequences; then we can’t directly use the operator “+”.
Implement below code for adding sequences of unequal length:
end
Generate x1 and x2 given below
𝟏; 𝟏 ≤ 𝒏𝟏 ≤ 𝟗
𝒙𝟏 [𝒏𝟏] = {
𝟎; 𝒐𝒕𝒉𝒆𝒓𝒘𝒊𝒔𝒆
𝟏; 𝟑 ≤ 𝒏𝟐 ≤ 𝟏𝟎
𝒙𝟐 [𝒏𝟐] = {
𝟎; 𝒐𝒕𝒉𝒆𝒓𝒘𝒊𝒔𝒆
Add x1[n] and x2[n] using function “sigadd”.
Signal multiplication is implemented in MATLAB by using the array operator “.*”. However, the
length of x1(n) and x2(n) must be same. If sequences are of unequal length, or if the sample
positions are different for equal length sequences; then we can’t directly use the operator “.*”.
Implement below code for multiplying sequences of unequal length:
29
Signals And Systems Lab Manual EL-315
%
n=min(min(n1),min(n2)):max(max(n1), max(n2)); % duration of y(n)
y1=zeros(1,length(n)); y2=y1; % initiallization
y1(find((n>=min(n1))&(n<=max(n1))==1))=x1;
y2(find((n>=min(n2))&(n<=max(n2))==1))=x2;
y=y1.*y2;
end
Multiply both the signals defined in task4 x1 [n] and x2 [n] using the above function
“sigmult”
TASK 3: SCALING
Scale both the signals defined in task4 x1 [n] and x2 [n] such that we get 2x1 [n] ,5x2 [n].
Show the results to the instructor.
TASK 4: SHIFTING
In this each sample of “x(n)” is shifted by an amount “k” to obtain a shifted sequence “y(n)”
30
Signals And Systems Lab Manual EL-315
TASK 5: FOLDING
In this operation each sample of “x(n)” is flipped around n=0, to obtain a folded sequence
“y(n)”
In MATLAB this operation is implemented by “fliplr(x)” function for sample values and by
“flipper(n)” function for sample positions as shown in the “sigfold” function.
Fold the signal obtained in the task5 [n] , and show to the instructor.
This operation differs from signal addition operation. It adds all sample values of x(n) between
x1(n) and x2(n).
𝐧𝟐 (4-12)
∑ 𝐱(𝐧) = 𝐱(𝐧𝟏) + ⋯ + 𝐱(𝐧𝟐)
𝐧=𝐧𝟏
ss = sum(x(n1:n2));
31
Signals And Systems Lab Manual EL-315
What result you have concluded from the functions “sigadd” and “sum”
This operation also differs from the signal multiplication operation. It multiplies all sample
values of x(n) between n1 and n2.
𝐧𝟐
(4-13)
∏ 𝐱(𝐧) = 𝐱(𝐧𝟏 ) × … × 𝐱(𝐧𝟐 )
𝐧𝟏
sp = prod(x(n1:n2));
32
Signals And Systems Lab Manual EL-315
Split the signal obtained in the task5 y[n] into its even and odd parts and show to the
instructor.
Use stem function and plot ye,yo , and compare it to the y[n]
33
Signals And Systems Lab Manual EL-315
LAB ASSIGNMENT
P.1
Generate
𝒙(𝒏) = 𝒆(−𝒋𝟒𝝅𝒏) , 𝟎 ≤ 𝒏 ≤ 𝟏𝟎
P.2
𝒙(𝒏) = 𝒆(−𝟒𝝅𝒏) , 𝟎 ≤ 𝒏 ≤ 𝟏𝟎
Plot its even and odd part, andshow the graph in which all x(n), xe(n) and xo(n) are given using
subplot command.
33
Signals And Systems Lab Manual EL-315
Observations/Comments/Explanation of Results:
34
Signals And Systems Lab Manual EL-315
Questions:
35
Signals And Systems Lab Manual EL-315
Roll #:_____________________________
OBJECTIVES:
INTRODUCTION
A system is a collection of elements or components that are organized for a common purpose.
Physical systems in the broad sense are an interconnection of components, devices or
subsystems.
CONTINUOUS-TIME SYSTEM
This is a system in which continuous-time signals are applied and result in continuous-time
output, such a system has x(t) and y(t) as input and output respectively.
DISCRETE-TIME SYSTEM
CLASSIFICATION
LINEAR SYSTEM
36
Signals And Systems Lab Manual EL-315
∝ ∝
(5-3)
𝒚(𝒏) = 𝑳[𝒙(𝒏)] = 𝑳[ ∑ 𝒙(𝒌)𝜹(𝒏 − 𝒌) = ∑ 𝒙(𝒌)𝑳(𝒏 − 𝒌)
𝒏=−∝ 𝒏=−∝
L(n − k)is called the response of linear system , called the impulse response.
A linear system in which an input-output pair, x(n) and y(n) , is invariant to a shift n in time is
called a linear time-invariant system. For this system L[ . ] and shifting operators are reversible
as shown below.
∝
(5-4)
𝒚(𝒏) = 𝑳𝑻𝑰[𝒙(𝒏)] = ∑ 𝒙(𝒙)𝒉(𝒏 − 𝒌)
𝒌=−∝
Hence we can say that LTI system is completely characterized in the time domain by the
impulse response h(n) as shown below.
STABILITY
The primary reason for considering stability is to avoid building harmful systems or to avoid
burnout or saturation in the system operation. A system is said to be bounded-input bounded–
output (BIBO) stable if every bounded input produces a bounded output.
37
Signals And Systems Lab Manual EL-315
∝
(5-5)
𝑩𝑰𝑩𝑶𝑺𝒕𝒂𝒃𝒊𝒍𝒊𝒕𝒚 ⇔ ∑|𝒉(𝒏)| <∝
−∝
CAUSALITY
A system is said to be causal if the output at index “no” depends only on the input up to and
including the index “no” i.e. the output doesn’t depend on the future values of the input. An LTI
system is causal if and only if the impulse response
An LTI discrete system can also be described by a linear constant coefficient difference equation
of the form
𝑵 𝑴
(5-7)
∑ 𝒂𝒌 𝒚(𝒏 − 𝒌) = ∑ 𝒃𝒎 𝒙(𝒏 − 𝒎),
𝒌=𝟎 𝒎=𝟎
This equation describes the recursive approach for computing the current output, given the
input values and previously computed output values. In practice this equation is computed
forward in time, from n = −∝ to n =∝ . Therefore another form of the equation is
𝑴 𝑵
(5-8)
𝒚(𝒏) = ∑ 𝒃𝒎 𝒙(𝒏 − 𝒎) − ∑ 𝒂𝒌 𝒚(𝒏 − 𝒌)
𝒎=𝟎 𝒌=𝟏
38
Signals And Systems Lab Manual EL-315
𝒚𝒉 (𝒏) = ∑ 𝒄𝒌 𝒛𝒌 𝒏 (5-10)
𝒌=𝟏
Where zk , k= 1,……. N, are N roots (also called natural frequencies) of the characteristic
equation.
∑ 𝒂 𝒌 𝒛𝒌 (5-11)
𝟎
|z𝑘 | < 1, 𝑘 = 1, … … . . , 𝑁
LAB TASK
Note: make m-file, show function’s plot, xlabel, ylabel,hold,stem and observe the output and
show to the instructor, see MATLAB help.
A routine called the FILTER is available to solve difference equations numerically , given the
input and the difference equation coefficients. This routine is invoked by
y = filter (b, a, x)
Where
X is input sequence array. Y output has the same length as input x. One must ensure that
coefficient a0 not to be zero.
39
Signals And Systems Lab Manual EL-315
b=[1];
a=[1 -1 0.9];
x= impseq(0, -20, 120); n = [-120:120];
h=filter(b,a,x);
subplot(2,1,1); stem(n,h);title (‘impulse response’); xlabel(‘n’); ylabel(‘h(n)’)
40
Signals And Systems Lab Manual EL-315
To determine the stability of the system, we have to determine h(n)for all n. We can
use the plot of impulse response to observe that h(n) is practically zero for n > 120.
Hence the sum ∑|h(n)| can be determined from MATLAB using:
≫sum(abs(h))
≫ans =14.8785
Which implies that the system is stable. An alternate approach is to use the MATLAB
stability condition using MATLAB’s root function.
≫z = roots(a);
≫magz = abs(z)
Magz = 0.9487
0.9487
Since the magnitudes of both roots are less than one, the system is stable.
41
Signals And Systems Lab Manual EL-315
LAB ASSIGNMENT
P1. A particular linear and time-invariant system is described by the difference equations
42
Signals And Systems Lab Manual EL-315
Observations/Comments/Explanation of Results:
43
Signals And Systems Lab Manual EL-315
Questions:
44
Signals And Systems Lab Manual EL-315
Roll #:_____________________________
OBJECTIVES:
INTRODUCTION
We have defined the systems and their types in the previous lab session. In this lab we will
discuss the properties of LTI (Linear Time Invariant) systems. Linearity and time invariance play
a fundamental role in signal and system analysis. Many physical processes possess these
properties and thus can be modeled as linear time invariant (LTI) systems. One of the primary
reasons LTI systems are amenable to analysis is that these systems possess the superposition
property. As a consequence, if we can represent the input of an LTI system in terms of a linear
combination of a set of basic signals, we can then use superposition to compute the output of
the system in terms of its responses to these basic signals.
A linear system in which an input-output pair, x(n) and y(n) , is invariant to a shift n in time is
called a linear time-invariant system. For this system L[ . ] and shifting operators are reversible
as shown below.
∝
(6-1)
𝒚[𝒏] = 𝑳𝑻𝑰[𝒙[𝒏]] = ∑ 𝒙[𝒌]𝒉[𝒏 − 𝒌]
𝒌=−∝
Hence we can say that LTI system is completely characterized in the time domain by the
impulse response h[n] as shown below.
45
Signals And Systems Lab Manual EL-315
If x1(t) and x2(t) are to signals and are input to LTI system then by law of superposition we get as
below
(6-2)
𝑳[𝒂𝟏 𝒙𝟏 (𝒕) + 𝒂𝟐 𝒙𝟐 (𝒕)] = 𝒂𝟏 𝑳[𝒙𝟏 (𝒕)] + 𝒂𝟐 𝑳[𝒙𝟐 (𝒕)], ∀𝒂𝟏 , 𝒂𝟐 𝒙𝟏 (𝒕), 𝒙𝟐 (𝒕)
(6-3)
𝑳[𝒂𝟏 𝒙𝟏 [𝒏] + 𝒂𝟐 𝒙𝟐 [𝒏]] = 𝒂𝟏 𝑳[𝒙𝟏 [𝒏]] + 𝒂𝟐 𝑳[𝒙𝟐 [𝒏]], ∀𝒂𝟏 , 𝒂𝟐 , 𝒙𝟏 [𝒏], 𝒙𝟐 [𝒏]
Eq.1 and 2 represents law of superposition on continuous and discrete linear time invariant
systems.
The output of discrete-time LTI system is as follows where , h[n-k] denotes the response of
linear system to the shifted unit impulses 𝛿[𝑛 − 𝑘].
+∝
(6-4)
𝒚[𝒏] = ∑ 𝒙[𝒌]𝒉[𝒏 − 𝒌] = 𝒙[𝒏] ∗ 𝒉[𝒏]
−∝
(6-5)
+∝
𝒚(𝒕) = ∫ 𝒙(𝒌)𝒉(𝒕 − 𝒌). 𝒅𝒌 = 𝒙(𝒕) ∗ 𝒉(𝒕)
−∝
46
Signals And Systems Lab Manual EL-315
(6-8)
𝒙[𝒏] ∗ (𝒉𝟏 [𝒏] + 𝒉𝟐 [𝒏]) = 𝒙[𝒏] ∗ 𝒉𝟏 [𝒏] + 𝒙[𝒏] ∗ 𝒉𝟐 [𝒏]
(6-9)
𝒙(𝒕) ∗ (𝒉𝟏 (𝒕) + 𝒉𝟐 (𝒕)) = 𝒙(𝒕) ∗ 𝒉𝟏 (𝒕) + 𝒙(𝒕) ∗ 𝒉𝟐 (𝒕)
This property can be easily verified by the parallel interconnection of LTI systems.
Another important and useful property of convolution is that it is associative. That is, in discrete
time
(6-10)
𝒙[𝒏] ∗ (𝒉𝟏 [𝒏] ∗ 𝒉𝟐 [𝒏]) = (𝒙[𝒏] ∗ 𝒉𝟏 [𝒏]) ∗ 𝒉𝟐 [𝒏]
47
Signals And Systems Lab Manual EL-315
(6-11)
𝒙(𝒕) ∗ (𝒉𝟏 (𝒕) ∗ 𝒉𝟐 (𝒕)) = (𝒙(𝒕) ∗ 𝒉𝟏 (𝒕)) ∗ 𝒉𝟐 (𝒕)
A system is said to be memoryless if its output for each value of the independent variable at a
given time is dependent only on the input at the same time. For example, the system specified
by the relationship
Is memoryless, as value of y[n] depends only on the value of x[n] at that time.
48
Signals And Systems Lab Manual EL-315
CAUSALITY
A system is said to be causal if the output at index “no” depends only on the input up to and
including the index “no” i.e. the output doesn’t depend on the future values of the input. An LTI
system is causal if and only if the impulse response
(6-13)
𝒉[𝒏] = 𝟎 , 𝒏 > 0
STABILITY
An LTI system is BIBO stable if and only if its impulse response is absolutely summable.
(6-14)
∝
A system is time invariant if the behavior and characteristics of the system are fixed over time.
(6-15)
𝑦(𝑡) = 𝑘. 𝑥(𝑡)
𝑦(𝑡 − 𝑡𝑜) = 𝑘. 𝑥(𝑡 − 𝑡𝑜)
LAB TASK
TASK 1:
If x1[n]=sin[n],and x2[n]=cos[n], consider a system y[n]= x[n].cos[0.2*pi*n]. Show if y[n] is linear or not.
49
Signals And Systems Lab Manual EL-315
TASK 2:
Considering y[n] defined above show, if this systemis time variant or invariant.
Write the MATLAB code below, and the result you get on the command window.
TASK 3:
a. y1[n]=x[n]*h[n].
b. y2[n]=x[n]*h[n+2].
MATLAB CODE:
n=-10:10;
x=impseq(0,-10,10)+2.*impseq(1,-10,10)-impseq(3,-10,10);
h=2.*impseq(-1,-10,10)+2.*impseq(1,-10,10);
y1=conv(x,h);
y2=conv(x,sigshift(h,n,-2));
50
Signals And Systems Lab Manual EL-315
TASK 4:
TASK 5:
The following are the impulse responses of LTI-systems. Determine through MATLAB either
they are causal/stable. Taking -100<=n<=100
51
Signals And Systems Lab Manual EL-315
LAB ASSIGNMENT
P1.
a. y[n] is LTI-system.
b. Show x1,x2,x3 satisfy the commutative, distributive and associative law.
P2.
52
Signals And Systems Lab Manual EL-315
Observations/Comments/Explanation of Results:
53
Signals And Systems Lab Manual EL-315
Questions:
54
Signals And Systems Lab Manual EL-315
Roll #:_____________________________
OBJECTIVES:
INTRODUCTION
In this lab we will study continuous time convolution. The definition of convolution is a
mathematical operation on two functions to generate another function. In signals domain,
convolution is the operation on two signals to generate a new signal. Consider the following
system, now in continuous time:
Fig.7-1
The output y(t) will be the convolution of input x(t) and impulse response of the system h(t).
In continuous time convolution we take input, impulse response and the output in continuous
time. The output then is represented by the convolution integral given by:
∞ ∞
y(t) = x(t) ∗ h(t) = ∫−∞ x(τ)h(t − τ)dτ =∫−∞ h(τ)x(t − τ)dτ (7-1)
55
Signals And Systems Lab Manual EL-315
The difference between continuous time convolution and discrete time convolution is that in
discrete time we take samples of our signal but in continuous time we take signal on the whole.
It is equivalent to saying that when we make infinite samples of our signal, then the samples
will be very close to each other and the summation becomes integration and discrete time
convolution becomes continuous time convolution. So in continuous time convolution we use
integration rather than summation as described in the equation above.
Continuous time convolution is similar to discrete time convolution. Basic points to carry out
the convolution are bulleted below:
EXAMPLE OF CONVOLUTION
56
Signals And Systems Lab Manual EL-315
Fig 7-2
Fig.7-3
And finally the output of the convolution of x(t) and h(t) is given by:
57
Signals And Systems Lab Manual EL-315
Fig.7-4
58
Signals And Systems Lab Manual EL-315
LAB TASK
By reading out the pre lab document most of us would have an idea about convolution. But that
was how we can perform convolution mathematically. In this lab handout we will explain how
convolution is done in MATLAB. By following the explained step by step procedure, we will
learn convolution using MATLAB.
In the previous lab we performed convolution using ‘conv’ function. But problem with this built
in function is that is works only if the two signals are discrete time. This function is not defined
for continuous time signals. So, we cannot use ‘conv’ function in the case of continuous time
convolution.
There is no built in function for continuous time convolution in MATLAB. Then the obvious
question is how we can perform continuous convolution in MATLAB? Recall from your pre lab
handout that continuous time convolution is carried out by the expression:
∞ ∞
y(t) = x(t) ∗ h(t) = ∫−∞ x(τ)h(t − τ)dτ =∫−∞ h(τ)x(t − τ)dτ (7-2)
The integral used in the expression is the definite integral. MATLAB has a function called INT to
perform integration. To explore this function and its functionality type doc symbolic/int and
press enter.
59
Signals And Systems Lab Manual EL-315
LAB TASK
TASK 1:
>>doc symbolic/int
Write down what have you understood in “doc syms “ & “doc int “
TASK 2:
Let us consider the convolution of 1/(1+t2) with itself. That is let us calculate
2𝜋
1 1
∫ ∗ 𝑑𝜏
1 + 𝜏 1 + (𝑡 − 𝜏)2
2
−2𝜋
>>syms t tau
>> f=1/(1+t^2);
>> z=int(subs(f,tau)*subs(f,t-tau),tau,-2*pi,2*pi);
>> subplot(2,1,1);
>>ezplot(f);
>> xlabel(‘t’);
>>ylabel(‘f’);
>> subplot(2,1,2);
>> plot(z);
>> xlabel(‘t’);
60
Signals And Systems Lab Manual EL-315
>>ylabel(‘z’);
Fig.7-5
61
Signals And Systems Lab Manual EL-315
Fig.7-6
TASK 3:
Plot x(t), h(t) and y(t) in one window. (Hint: Use subplot).
Label y-axis of x(t), h(t) and y(t) as Input x(t), Impulse Response h(t) and Output y(t)
respectively.
62
Signals And Systems Lab Manual EL-315
TASK 4:
TASK 5:
63
Signals And Systems Lab Manual EL-315
64
Signals And Systems Lab Manual EL-315
LAB ASSIGNMENTS
62
Signals And Systems Lab Manual EL-315
Observations/Comments/Explanation of Results:
63
Signals And Systems Lab Manual EL-315
Questions:
1. What is convolution.
2. Explain types of convolution.
3. What are different steps to carry out convolution?
4. How will you find convolution in MATLAB?
5. What is the difference between plot and stem?
6. How will you apply grid on graphs?
7. How will you write x(t) in MATLAB?
x(t) = u(t-2) – u(t-4)
8. Explain ‘syms’.
9. Explain ‘int’.
10. Explain ‘ezplot’.
64
Signals And Systems Lab Manual EL-315
OBJECTIVES:
INTRODUCTION
x[n] y[n]
h[n]
Fig.8-1
The output y[n] will be the convolution of input x[n] and impulse response of the system will be
h[n].
TYPES OF CONVOLUTION
1. CONTINUOUS TIME
In continuous time convolution we take input, impulse response and the output in continuous
time. The output then is represented by the convolution integral given by:
65
Signals And Systems Lab Manual EL-315
∞ ∞ (8-1)
y(t) = x(t) ∗ h(t) = ∫−∞ x(τ)h(t − τ)dτ=∫−∞ h(τ)x(t − τ)dτ
2. DISCRETE TIME
In discrete time convolution we take input, impulse response and the output in discrete time.
The output then is represented by the convolution sum given by:
Convolution is a step-by-step procedure. Basic points to carry out the convolution are bulleted
below:
EXAMPLE OF CONVOLUTION
66
Signals And Systems Lab Manual EL-315
Fig.8-2
Fig.8-3
And finally the output of the convolution of x[n] and y[n] is given by:
67
Signals And Systems Lab Manual EL-315
Fig.8-4
68
Signals And Systems Lab Manual EL-315
LAB TASK
By reading out the pre lab document most of us would have an idea about convolution. But that
was how we can perform convolution mathematically. In this lab handout we will explain how
convolution is done in MATLAB. By following the explained step by step procedure, we will
learn convolution using MATLAB.
MATLAB provides a built in function named conv(x,h) that computes the convolution of two
signals. Let us take on an example to explore this function.
EXAMPLE
>> x = [3,11,7,0,-1,4,2];
>> h = [2,3,0,-5,2,1];
>> y = conv(x,h)
y=
6 31 47 6 -51 -5 41 18 -22 -3 8 2
This convolution functions proves to be very useful but it misses one of the most important
things of convolution which is discussed below.
69
Signals And Systems Lab Manual EL-315
The conv function assumes that the two sequences begin at n = 0. Moreover, this function
neither provides nor accepts any timing information if the sequences have arbitrary starting
points. What is required is the beginning and end point of y[n]. Given finite duration x[n] and
h[n], it is easy to determine these points. Let
And
be the two finite duration sequences, then starting and end points of y[n] can be written as
Now we can define our own function in MATLAB that is slightly modified from the built in conv
function. Our modified function will use the conv function as underlying function but it will
perform convolution of arbitrary support sequences. How to define our own function?
First go to File and then click New and then M-File. Write the following code in the newly
opened editor file.
ny = [nyb : nye];
y = conv(x,h);
70
Signals And Systems Lab Manual EL-315
end
This is our own defined function named myconv. Now we can use this function just as any other
function in MATLAB.
Now we will use this function for the convolution of signals having arbitrary starting and ending
points. Consider the signals in previous example
>> x = [3,11,7,0,-1,4,2];
>>nx = [-3:3];
>> h = [2,3,0,-5,2,1];
>>nh = [-1:4];
y=
6 31 47 6 -51 -5 41 18 -22 -3 8 2
ny =
-4 -3 -2 -1 0 1 2 3 4 5 6 7
Now this function also shows the starting and ending points of y[n] and values are
corresponding indices. We can plot this y[n] by the commands:
>> stem(ny,y);
>> xlabel('n');
>>ylabel('y[n]');
>> title('Convolution');
71
Signals And Systems Lab Manual EL-315
Fig.8-5
TASK4:
Both input and impulse response is taken to be the same for the sake of simplicity. We define
output as the convolution of input and impulse response.
72
Signals And Systems Lab Manual EL-315
x[n] = 1, 0 ≤ n ≤ 4
0, otherwise
h[n] = 0.5n, 0 ≤ n ≤ 6
0, otherwise
73
Signals And Systems Lab Manual EL-315
LAB ASSIGNMENTS
P.1
When the convolution of a signal is performed with itself, it is called correlation which is a very
important concept in communications. This task is related to this concept. You have to convolve
the signal with itself. The signal is given by:
x[n] = 1, -2≤n≤0
-1, 0<n≤2
73
Signals And Systems Lab Manual EL-315
Observations/Comments/Explanation of Results:
74
Signals And Systems Lab Manual EL-315
Questions:
1. What is convolution.
2. Explain types of convolution.
3. What are different steps to carry out convolution?
4. How will you find convolution in MATLAB?
5. What is the difference between plot and stem?
6. How will you apply grid on graphs?
7. How will you write x[n] in MATLAB?
x[n] = 1, 0 ≤ n ≤ 4
0, otherwise
75
Signals And Systems Lab Manual EL-315
OBJECTIVES:
INTRODUCTION
Transforms are used extensively in engineering to change the frame of reference between the
time domain and the frequency domain. Many techniques exist for analyzing steady-state and
smoothly changing systems in the time domain, but complex systems often can be more easily
analyzed in other domains.
Fourier series and the Fourier transform play a vital role in many areas of engineering such as
communications and signal processing. These representations are among the most powerful
and most common methods of analyzing and understanding signals. A solid understanding of
Fourier series and the Fourier transform is critical to the design of filters and is beneficial in
developing the understanding of many natural phenomena.
FOURIER SERIES
Almost all periodic signals can be represented as an infinite sum of sine and cosines. This sum is
called a Fourier series representation and is defined for a periodic function x(t) of period T with
the following equation,
∞
(9-1)
𝒂𝟎 𝟐𝝅𝒏𝒕 𝟐𝝅𝒏𝒕
𝒙(𝒕) = + ∑ (𝒂𝒏 𝐜𝐨𝐬 + 𝒃𝒏 𝐬𝐢𝐧 )
𝟐 𝑻 𝑻
𝒏=𝟏
Where a0, an and bn are the Fourier series coefficients. These coefficients can be calculated by
applying the following equations:
𝑻 𝑻 (9-2)
𝟐 𝟐𝝅𝒏𝒕 𝟐 𝟐𝝅𝒏𝒕
𝒂𝒏 = ∫ 𝒙(𝒕) 𝐜𝐨𝐬 𝐝𝐭 𝐚𝐧𝐝 𝒃𝒏 = ∫ 𝒙(𝒕) 𝐬𝐢𝐧 𝐝𝐭
𝑻 𝑻 𝑻 𝑻
𝟎 𝟎
76
Signals And Systems Lab Manual EL-315
If the Fourier coefficients are written as a single complex number cn with real part representing
the coefficients of the cosine series and imaginary parts representing coefficients of the sine
series, we can write the complex form of the Fourier series as
1 𝑇
x(t) = ∑+∞
−∞ cn𝑒 (𝑗2𝜋𝑛𝑡/𝑇) with cn = 𝑇 ∫0 𝑥(𝑡) 𝑒 (−𝑗2𝜋𝑛𝑡/𝑇) n = 0, 1, 2....
LAB TASK
TASK1:
In this section we take an arbitrary saw tooth wave and plot it. Next we plot the magnitude and
phase of the Fourier co-efficient. Then reconstruct the saw tooth wave by combining various
harmonics.
77
Signals And Systems Lab Manual EL-315
Figure 9-1
78
Signals And Systems Lab Manual EL-315
Figure 9-2
79
Signals And Systems Lab Manual EL-315
TASK3:
function [Xk]=dfs(xn,N)
%computes discrete fourier series coefficients
n=[0:1:N-1];
k=[0:1:N-1];
WN=exp(-j*2*pi/N);
nk=n'*k;
WNnk=WN.^nk;
Xk=xn*WNnk;
end
and
Write the MATLAB code given above for DFS and calculate Xk;
stem x1(n), x2(n) and Xk1(n) and Xk2(n)in one window. (Hint: Use subplot).
Label x-axis of all three graphs as n
Label y-axis of x1(n), x2(n) and Xk1(n) and Xk2(n) respectively.
Apply grid on all three graphs.
TASK4:
As by definition,
∞
𝑎0 2𝜋𝑛𝑡 2𝜋𝑛𝑡
𝑥(𝑡) = + ∑ (𝑎𝑛 cos + 𝑏𝑛 sin )
2 𝑇 𝑇
𝑛=1
and
80
Signals And Systems Lab Manual EL-315
𝑇 𝑇
2 2𝜋𝑛𝑡 2 2𝜋𝑛𝑡
𝑎𝑛 = ∫ 𝑥(𝑡) cos dt and 𝑏𝑛 = ∫ 𝑥(𝑡) sin dt
𝑇 𝑇 𝑇 𝑇
0 0
If , our x(t)= sin(t) , with T=2∏, then find out the values of an, bn, and calculate x(t).
81
Signals And Systems Lab Manual EL-315
LAB ASSIGNMENT
And
−0.3𝑛
𝑥2(𝑛) = { 𝑛𝑒 , 0 ≤ 𝑛 ≤ 25 , 𝑁 = 100
0 26 ≤ 𝑛 ≤ 99
82
Signals And Systems Lab Manual EL-315
Observations/Comments/Explanation of Results:
83
Signals And Systems Lab Manual EL-315
Questions:
84
Signals And Systems Lab Manual EL-315
OBJECTIVES:
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
+∞ 𝟏 +∞ (10-1)
X(ω) = ∫−∞ 𝒙(𝒕)𝒆−𝒋𝝎𝒕 dt ; x(t) = ∫ 𝑿(𝝎) 𝒆𝒋𝝎𝒕 dω
𝟐𝝅 −∞
MATLAB used the fourier and ifourier functions to transform expressions between domains.
>>help fourier
>>help ifourier
85
Signals And Systems Lab Manual EL-315
LAB TASK
TASK1.
>>doc fourier
Write about ‘fourier ’what you have understood.
>>syms t
>>x1 = t*exp(-t^2) % hit enter and write the output
x1=
TASK2.
Often when using the Fourier transform to solve engineering problems, expressions can include
a step function u(t) and/or impulse function δ(t).
86
Signals And Systems Lab Manual EL-315
f2 =
Ans=
if2 =
>>ans=
TASK 3.
x3=
f3 =
>>ezplot (abs(f3))
87
Signals And Systems Lab Manual EL-315
Figure 10-1
>>ezplot ( abs (f3) , [ -10 10] )
Figure 10-2
>>syms w
>>ezplot ( w , abs ( f3) , [ -5 5 -10 10 ] )
88
Signals And Systems Lab Manual EL-315
Figure 10-3
>> axis ( [ -5 5 -10 10 ] );
Figure 10-4
QUESTION: - What is the difference in the three plots???
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
89
Signals And Systems Lab Manual EL-315
LAB ASSIGNMENT
P1.
P2.
Plot the Fourier and its inverse transforms of: sine(t)*e– 10tu (t).
90
Signals And Systems Lab Manual EL-315
Observations/Comments/Explanation of Results:
91
Signals And Systems Lab Manual EL-315
Questions:
92
Signals And Systems Lab Manual EL-315
OBJECTIVES:
INTRODUCTION
The Fourier transform is in general complex valued and can be represented in terms of its real
and imaginary components or in terms of magnitude and phase.
93
Signals And Systems Lab Manual EL-315
From the convolution property for continuous-time Fourier transforms, transform 𝑌(𝑗𝜔) of the
output of an LTI system is related to the transform 𝑋(𝑗𝜔) of the input to the system by the
equation below.
|𝑌(𝑗𝜔)|=|𝑋(𝑗𝜔)||𝐻(𝑗𝜔)|
When the phase shift at the frequency ω is a linear function of ω , there is a particularly
straightforward interpretation of the effect in the time domain. Consider the continuous-time
LTI system with frequency response.
𝐻(𝑗𝜔) = 𝑒 −𝑗𝜔𝑡𝑜
So that the system has unit gain and linear phase. i.e
The system with this frequency response characteristic produces an output that is simply a time
shift of the input.
94
Signals And Systems Lab Manual EL-315
GROUP DELAY
In continuous-time, if ≮ 𝐻(𝑗𝜔)= -ωto, then system imparts a time shift of –to, or equivalently,
a delay of to. The concept of delay can be very naturally and simply extended to include
nonlinear phase characteristics. Group delay at each frequency equals the negative of the
slope of the phase at that frequency. Group delay is defined as
𝑑
𝜏(𝜔) = − |≮ 𝐻(𝑗𝜔)|
𝑑𝜔
The phase relationship is additive, while the magnitude relationship involves the product of
|𝐻(𝑗𝜔)| and |𝑋(𝑗𝜔)|. Thus, if the magnitudes of the Fourier transform are displayed on a
logarithmic amplitude scale then it takes the form of an additive relationship, namely
Consequently, if we have a graph of the log magnitude and phase of the Fourier transform of
the input and the frequency response of LTI system, the Fourier transform of the output is
obtained by adding the log-magnitude plots and by adding the phase plots. In addition,
plotting the magnitude on logarithmic scale allows detail to be displayed over a wider
dynamic range.
NOTE:
Typically, the specific, logarithmic amplitude scale used is in units of 20log10, referred to as
decibels (db). 0db corresponds to a frequency with magnitude equal to 1, 20 db is equal to 10,
and -20 shows 0.1 attenuation and so on. 6db corresponds to a gain of 2.
95
Signals And Systems Lab Manual EL-315
LAB TASK
Note: show function’s plot,xlabel,ylabel,hold,ezplot and observe the output and show to the
instructor, see MATLAB help.
TASK 1:
syms x;
f = exp(-x^2)*heaviside(x) %Hit enter
fourier(f) %Hit enter
returns
TASK 2:
10
𝑖𝑓𝑥(𝑡) = 𝑒 −5𝑡 𝑢(𝑡), 0 ≤ 𝑡 ≤ 10 find 𝑥(𝑗𝜔) = ∫0 𝑒 −5𝑡 𝑒 −𝑗𝜔𝑡 𝑑𝑡
Solution:
syms t w
96
Signals And Systems Lab Manual EL-315
Fig 11-2. Shows the phase response of the above given function.
97
Signals And Systems Lab Manual EL-315
TASK 3:
syms t
ezplot(real(fr))
98
Signals And Systems Lab Manual EL-315
Fig 11-3. Shows that impulse has Fourier transform consisting of equal contributions at all
frequencies.
TASK 4:
𝒅𝒚(𝒕)
+ 𝟏𝟎𝒚(𝒕) = 𝒙(𝒕)
𝒅𝒙
Consider an LTI system represented by differential equation, find its frequency response.
Solution:
From eq. 5 as it represents the frequency response of LTI system, so we can represent the
above differential equation as :
syms t w
fr=1/j*w+10
>> subplot(2,1,1)
>>ezplot(real(fr))
99
Signals And Systems Lab Manual EL-315
>>ylabel('|fr|')
>> grid on
>> subplot(2,1,2)
>>ezplot(imag(fr))
>>ylabel('angle of fr')
>> grid on
>>gd =
100
Signals And Systems Lab Manual EL-315
LAB ASSIGNMENT
P.1
d. cos(𝜋62𝑡/10)
101
Signals And Systems Lab Manual EL-315
Observations/Comments/Explanation of Results:
102
Signals And Systems Lab Manual EL-315
Questions:
9. Explain ‘ezplot’.
103
Signals And Systems Lab Manual EL-315
Roll #:_____________________________
OBJECTIVES:
Be able to explain CONTINUOUS-VALUED versus DISCRETE-VALUED SIGNALS.
Be able to find Periods of Continuous and Discrete signals.
Be able to explain Signal Sampling Theorem and Nyquist Rate.
Be able to reconstruct the signal.
INTRODUCTION
CONTINUOUS-TIME SIGNALS
Continuous-time signals or analog signals are defined for every value of time and they take on
values in the continuous interval (a, b) , where ‘a’ can be -∞ or +∞. Mathematically these
functions are described by functions of a continuous-time variable.
DISCRETE-TIME SIGNALS
Discrete-time signals are defined only at certain specific values of time. These time instants
need not to be equidistant, but in practice they are usually taken as equally spaced intervals for
computational convenience and mathematical tractability. They may take real or complex
values.
CONTINUOUS-VALUED SIGNALS
104
Signals And Systems Lab Manual EL-315
DISCRETE-VALUED SIGNALS
If the signal takes on values from a finite set of possible values, it is said to be a discrete-valued
signal.
NOTE: A discrete-time signal having a set of discrete values is called a digital signal.
The concept of frequency is directly related to the concept of time. Actually frequency has the
dimension of inverse time. Thus nature of time will affect the nature of the frequency
accordingly.
𝑥𝑎(𝑡) denotes an analog signal. This signal is has amplitude A, frequency Ω, and phase θ.
Instead of Ω, we often use the frequency F in cycles per second or hertz (Hz) , where
𝛺 = 2𝜋𝐹
For fixed value of the frequency , F , 𝑥𝑎(𝑡) is periodic if Tp is fundamental time period
xa(t+ Tp) = xa(t)
105
Signals And Systems Lab Manual EL-315
Increasing the frequency F results in an increase in the rate of oscillation of the signal, in
the sense that more periods are included in a given time interval.
(12-3)
𝑥(𝑛) = 𝐴𝑐𝑜𝑠(𝜔𝑛 + 𝜃), −∞ < 𝑛 < +∞
𝑥(𝑛) denotes an discrete signal. This signal is has amplitude A, frequency ω , and phase θ.
Instead of 𝜔, we often use the frequency 𝑓 in cycles per second or hertz (Hz) , where
𝜔 = 2𝜋𝑓
(12-4)
𝑥(𝑛) = 𝐴𝑐𝑜𝑠(2𝜋𝑓𝑛 + 𝜃), −∞ < 𝑛 < +∞
The relationship is true for discrete-time signal periodicity if there exits an integer k such
that
2𝜋𝑓0 𝑁 = 2𝑘𝜋
𝑓0 = 𝑘/𝑁
Where k, and N are relative prime numbers after canceling common factor.
106
Signals And Systems Lab Manual EL-315
Increasing the frequency F results in an increase in the rate of oscillation of the signal, in
the sense that more periods are included in a given time interval.
Signals such as speech, radar and sonar signals in practical use are all analog signals. In order to
apply digital processing methods to these signals, we have to convert them into the form
required i.e. the digital form. This procedure is termed Analog-to-Digital conversion is carried
out by ADC’s (Analog-to-Digital converters).
1. Sampling
This step involves converting continuous time signal to discrete time signals. This is done by
taking samples i.e. a continuous time signal input xa(t) will give an output in the discrete form
xa(nT) ≡ x(n) where T is the sampling interval.
2. Quantization
In this step, the discrete time continuous –valued signal is converted into a discrete-time,
discrete-valued (digital) system. The signal sample value is selected from a set of finite possible
values. The difference between unquantized sample (x(n)) and the quantized output (xq(n) ) is
the quantization error.
3. Coding
Although many types of analog sampling techniques are available, periodic or uniform will be
discussed in this practical.
107
Signals And Systems Lab Manual EL-315
(12-5)
𝑥(𝑛) = 𝑥𝑎 (𝑛𝑇), − ∞ < 𝑛 <∞
Where :
x(n) Discrete time signal obtained by taking samples of the analog signal every T seconds
Sampling rate (samples per second)/sampling frequency- this is the reciprocal of T which is
equal to 1/Fs
These two variables are linearly related through the sampling period T or through the sampling
rate Fs=1/T as
𝑛 (12-6)
𝑡 = 𝑛𝑇 =
𝐹𝑠
Due to the relationship stated above there exists another resultant relationship between the
frequency variable F (or Ω) for analog signals and the frequency variable f (or ω) for discrete
time signals.
(12-7)
𝑥𝑎 (𝑡) = 𝐴cos(2πFt+θ)
108
Signals And Systems Lab Manual EL-315
(12-8)
𝑥𝑎 (𝑛𝑇) ≡ 𝑥(𝑛) = 𝐴cos(2πFt+θ)
2𝜋𝑛𝐹
= 𝐴 cos ( + 𝜃)
𝐹𝑠
(12-9)
𝑥(𝑛) = 𝐴cos(ωn+θ)
𝐹 (12-10)
𝑓=
𝐹𝑠
And,
(12-11)
𝜔 = Ω𝑇
SAMPLING THEOREM
If the highest frequency obtained in an analog signal xa(t) is Fmax =B (where B=bandwidth ) and
the signal is sampled at a rate Fs>2Fmax then xa(t) can be exactly recovered from its sample
values using the interpolation function below:
109
Signals And Systems Lab Manual EL-315
(12-12)
𝑠𝑖𝑛2𝜋𝐵𝑡
𝑔(𝑡) =
2𝜋𝐵𝑡
(12-13)
𝑛 𝑛
𝑥𝑎 (𝑡) = ∑ 𝑥𝑎 ( )𝑔(𝑡 − )
𝐹𝑠 𝐹𝑠
Where :
When the sampling of xa(t) is performed at the minimum sampling rate Fs=2B, the
reconstruction formula (8) becomes :
(12-14)
𝑛 sin 2𝜋𝐵(𝑡 − 𝑛/2𝐵)
𝑥𝑎 (𝑡) = ∑ 𝑥𝑎 ( ) )
2𝐵 2𝜋𝐵(𝑡 − 𝑛/2𝐵)
LAB TASK
TASK 1:
Solution.:
110
Signals And Systems Lab Manual EL-315
X1=cos(2*pi*(10/40)*n)
X2=cos(2*pi*(50/40)*n)
TASK 2:
if 𝑥𝑎(𝑡) = 3cos(300𝜋𝑡) and Fs =700 , then find ω and 𝑓 write MATLAB Command.
Solution:
F=300*pi/2*pi;
f=F/Fs;
TASK 3:
Let us now concentrate on the cosine signal of the form x[n] = Acos(w n +φ ) , where we have
renamed the amplitude as A. We willchange the parameter w0 to see its effect on periodicity.
We will take A as 1, φ as as0 and w0 as 1, π /4 and 3π /4 and generate and plot the
corresponding signals. For the first one, i.e. the cosine with w0 = 1, we will also plot an
envelope to better see that the signal is not periodic.
n=-10:0.1:10;
» w0=1;xn1=cos(w0*n);
111
Signals And Systems Lab Manual EL-315
» stem(n,xn1);hold on
» t=-10:0.1:10;
» xt=cos(t);
» plot(t,xt,'r');hold off
» axis([-10.5 10.5 -1 1]);xlabel('n');ylabel('x[n]')
» title('A Nonperiodic Discrete Time Cosine Signal')
» w0=pi/4;xn2=cos(w0*n);
» subplot(2,1,1);stem(n,xn2)
» w0=3*pi/4;xn3=cos(w0*n);
» subplot(2,1,2);stem(n,xn3);xlabel('n')
TASK 4:
close all;
clear all;
t=-10:0.01:10;
T=8;
fm=1/T;
x=cos(2*pi*fm*t);
fs1=1.2*fm;
fs2=2*fm;
fs3=8*fm;
n1=-4:1:4;
xn1=cos(2*pi*n1*fm/fs1);
subplot(221)
plot(t,x);
112
Signals And Systems Lab Manual EL-315
xlabel('time in seconds');
ylabel('x(t)');
subplot(222)
stem(n1,xn1);
hold on;
plot(n1,xn1);
xlabel('n');
ylabel('x(n)');
n2=-5:1:5;
xn2=cos(2*pi*n2*fm/fs2);
subplot(223)
stem(n2,xn2);
hold on;
plot(n2,xn2);
xlabel('n');
ylabel('x(n)');
n3=-20:1:20;
xn3=cos(2*pi*n3*fm/fs3);
subplot(224)
stem(n3,xn3);
hold on;
113
Signals And Systems Lab Manual EL-315
plot(n3,xn3);
xlabel('n');
ylabel('x(n)');
TASK 5:
t=0:.1:20;
F1=.1;
F2=.2;
x=sin(2*pi*F1*t)+sin(2*pi*F2*t);
%plotting
figure(1);
subplot(2,1,1);
plot(t,x);
title('Original signal')
xlabel('t');
ylabel('x(t)');
subplot(2,1,2);
stem(x_samples,'filled');
title('Sampled signal')
xlabel('n');
ylabel('x_s(n)');
axis([0 20 -2 2]);
114
Signals And Systems Lab Manual EL-315
TASK 6:
figure(2);
messagebox=msgbox(information,'Information','help');
subplot(2,1,2);
plot(t,x,'black');
hold on;
hold off;
xlabel('t');
ylabel('x(t)');
title('Original signal');
grid;
x_recon=0;
subplot(2,1,1);
for k=0:length(x_samples)-1
stem(0:length(x_samples)-1,x_samples,'filled');
if k==length(x_samples)-1
title('Reconstruction finished');
else
end
grid on;
115
Signals And Systems Lab Manual EL-315
l=k:-.1:-20+k;
x_recon=x_recon+x_samples(k+1)*sinc(l);
axis([0 20 -2 2]);
hold;
plot(t,x_samples(k+1)*sinc(l),'r')
plot(t,x_recon);
hold off;
waitforbuttonpress;
end
116
Signals And Systems Lab Manual EL-315
LAB ASSIGNMENT
P.1
Determine which of the following sinusoidals are periodic and compute their fundamental
period.
e. cos(𝜋30𝑛/105)
f. sin(𝜋62𝑛/10)
P.2
Determine whether or not each of the following signals is periodic. In case a signal is periodic
, specify its fundamental period.
P.3
117
Signals And Systems Lab Manual EL-315
Observations/Comments/Explanation of Results:
118
Signals And Systems Lab Manual EL-315
Questions:
1. Explain the difference between continuous time signals and discrete time signals.
2. Explain the difference between continuous valued signals and discrete valued signals.
3. Explain Sampling.
4. Explain Quantization.
5. Explain Signal Reconstruction.
6. Explain properties of analogue signals.
7. Explain properties of discrete sinusoidal signals.
8. What is sampling frequency?
9. What is nyquist rate?
10. What is the period of 𝑥(𝑛) = 3𝑐𝑜𝑠(5𝑡 + 𝜋/6)
119
Signals And Systems Lab Manual EL-315
OBJECTIVES:
Be able to explain Z- Transform: Uni-lateral and Bi-lateral
Be able to observe properties of Z-transform: Linearity, Sample Shifting, Frequency
Shifting, Folding, Complex Conjugation, Differentiation, Multiplication, and Convolution.
THE Z-TRANSFORM
∝
(13-1)
𝐗(𝐳) = 𝐙[𝐱(𝐧)] = ∑ 𝐱(𝐧) 𝐳 −𝐧
𝐧=−∝
Where “z” is a complex variable. The set of z values for which X(z) exists is called the region of
convergence (ROC) is given by
120
Signals And Systems Lab Manual EL-315
1. LINEARITY
2. SAMPLE SHIFTING
3. FREQUENCY SHIFTING
𝒛 (13-4)
𝒁[𝒂𝒏 𝒙(𝒏)] = 𝑿 ( ) =; 𝑹𝑶𝑪 ∶ 𝑹𝑶𝑪𝒙𝒔𝒄𝒂𝒍𝒆𝒅𝒃𝒚|𝒂|
𝒂
4. FOLDING
𝟏 (13-5)
𝒁[𝒙(−𝒏)] = 𝑿 ( ) =; 𝑹𝑶𝑪 ∶ 𝒊𝒏𝒗𝒆𝒓𝒕𝒆𝒅𝑹𝑶𝑪𝒙
𝒛
5. COMPLEX CONJUGATION
𝐝𝐗(𝐳) (13-7)
𝐙[𝐧𝐱(𝐧)] = −𝐳
𝐝𝐳
7. MULTIPLICATION
121
Signals And Systems Lab Manual EL-315
𝒁[𝒙𝟏(𝒏)𝒙𝟐(𝒏)] (13-8)
𝟏
= ∮ 𝑿𝟏(𝒗)𝑿𝟐(𝒛⁄𝒗)𝒗−𝟏 𝒅𝒗; 𝑹𝑶𝑪 ∶ 𝑹𝑶𝑪𝒙𝟏 ∩ 𝒊𝒏𝒕𝒆𝒓𝒕𝒆𝒅𝑹𝑶𝑪𝒙𝟐
𝟐𝝅𝒋
𝒄
8. CONVOLUTION
LAB TASK
TASK 1:
syms n;
f = n^4;
T1=ztrans(f)
T1 =
ezplot(T1)
TASK 2:
syms a z;
g = a^z;
T2=ztrans(f)
T2 =
ezplot(T2)
TASK 3:
syms a n w;
f = sin(a*n);
T3=ztrans(f , w)
T3 =
ezplot(T3)
122
Signals And Systems Lab Manual EL-315
TASK 4:
≫ x3 =[6,17,34,43,38,24];
≫ x1=[2,3,4];
≫ [x2,r] =deconv(x3,x1);
x2 =
r=
TASK 5:
In MATLAB the function ‘residuez’ is available to compute the residue part and direct (or
polynomial) terms of a rational function in 𝐳−𝐳 .
z
X(Z) =
3z2 − 4z + 1
Solution.
First rearrange X(Z) so that it is a function in ascending powers of z−1 .
z−1
X(Z) =
3 − 4z−1 + z−2
≫ b=[0,1];
≫ a=[3,-4,1];
≫ [R,p,C]=residuez[b,a];
R =
P =
C =
So,
0.5 0.5
X(Z) = −1
−
1−z 1 − 0.333z−1
123
Signals And Systems Lab Manual EL-315
TASK 5:
≫ [b,a]=residuez[R,p,C]
b =
a =
So that
1
0 + z −1 z −1 z
x(z) = 3 = = 2
4 −1 1 −2 −1
3 − 4z + 1z −2 3z − 4z + 1
1− z + z
3 3
TASK 6:
Pole-zero plots
z
X(Z) =
3z 2 − 4z + 1
We can find the roots of the denominator polynomial in the following two ways.
(a)We can plot the zeros and poles either with zeros and poles in column vectors
>> roots(den);
>>p=ans;
124
Signals And Systems Lab Manual EL-315
>>z=[0];
>>zplane(z,p)
≫den=[3 -4 1];
≫zplane(num,den)
125
Signals And Systems Lab Manual EL-315
LAB ASSIGNMENT
P1. For the given signal plot the pole-zero plot given below and write its code.
1
x(z) =
(1 − 0.9z −1 )2 (1 + 0.9z −1 )
126
Signals And Systems Lab Manual EL-315
Observations/Comments/Explanation of Results:
127
Signals And Systems Lab Manual EL-315
Questions:
1. Explain Z-Transform.
2. Explain Bilateral Z-Transform.
3. What is region of convergence?
4. Explain properties of Z-Transform.
5. What is complex conjugation?
6. What Matlab command is used to compute Z-Transform?
7. Explain ‘residuez’.
8. Explain ‘deconv’.
9. Explain ‘zplane’.
10. Expalin’roots’.
128
Signals And Systems Lab Manual EL-315
Roll #:_____________________________
OBJECTIVE:
INVERSE Z-TRANSFORM
SYNTAX
f = iztrans(F)
f = iztrans(F,k)
DESCRIPTION
f = iztrans(F) computes the inverse z-transform of the symbolic expression F. This syntax
assumes that F is a function of the variable z, and the returned value f is a function of n.
where R is a positive number, such that the function F(z) is analytic on and outside the circle
|z| = R.
f = f(k)
f = iztrans(F,k) computes the inverse z-transform f as a function of the variable k instead of the
default variable n.
f = iztrans(F,w,k) computes the inverse z-transform and lets you specify that F is a function of w
and f is a function of k.
129
Signals And Systems Lab Manual EL-315
9. LINEARITY
𝒛 (14-3)
𝒁[𝒂𝒏 𝒙(𝒏)] = 𝑿 ( ) =; 𝑹𝑶𝑪 ∶ 𝑹𝑶𝑪𝒙𝒔𝒄𝒂𝒍𝒆𝒅𝒃𝒚|𝒂|
𝒂
12. FOLDING
𝟏 (14-4)
𝒁[𝒙(−𝒏)] = 𝑿 ( ) =; 𝑹𝑶𝑪 ∶ 𝒊𝒏𝒗𝒆𝒓𝒕𝒆𝒅𝑹𝑶𝑪𝒙
𝒛
𝐝𝐗(𝐳) (14-6)
𝐙[𝐧𝐱(𝐧)] = −𝐳
𝐝𝐳
130
Signals And Systems Lab Manual EL-315
15. MULTIPLICATION
𝒁[𝒙𝟏(𝒏)𝒙𝟐(𝒏)] (14-7)
𝟏
= ∮ 𝑿𝟏(𝒗)𝑿𝟐(𝒛⁄𝒗)𝒗−𝟏 𝒅𝒗; 𝑹𝑶𝑪 ∶ 𝑹𝑶𝑪𝒙𝟏 ∩ 𝒊𝒏𝒕𝒆𝒓𝒕𝒆𝒅𝑹𝑶𝑪𝒙𝟐
𝟐𝝅𝒋
𝒄
16. CONVOLUTION
131
Signals And Systems Lab Manual EL-315
LAB TASK
TASK 1:
syms z
f = 2*z/(z-2)^2;
T1=iztrans(f)
returns
ans =
ezplot(T1)
FIGURE 14-1
132
Signals And Systems Lab Manual EL-315
TASK 2:
syms n
g = n*(n+1)/(n^2+2*n+1);
T2=iztrans(g)
returns
ans =
ezplot(T2)
TASK 3:
Then, take f, and g from task 1, and 2 and compute the given below
TL3=iztrans([5 ∗ f + 10 ∗ g])
C=5*T1
D=10*T2
TR3= 5 ∗ T1 + 10 ∗ T2
133
Signals And Systems Lab Manual EL-315
TASK 4:
symsa z
>> T4=1/(1-1/4*z^-1)
T4 =
-1/(1/(4*z) - 1)
>>iztrans(h)
ans =
ezplot(T4)
TASK 5:
syms a z
if T4=1/(1-1/4*z^-1) , then find and show the result graphically using ezplot
-zd(T4)/dz =
z^-7*T4 =
134
Signals And Systems Lab Manual EL-315
TASK 6:
0.5 0.5
X(Z) = −1
−
1−z 1 − 0.333z −1
For the given problem find the inverse z-transfrom and write ur MATLAB code below
MATLAB CODE
135
Signals And Systems Lab Manual EL-315
LAB ASSIGNMENT
P1.
0.5
P(Z) =
1 − z −1
136
Signals And Systems Lab Manual EL-315
Observations/Comments/Explanation of Results:
137
Signals And Systems Lab Manual EL-315
Questions:
138