Manual PDF
Manual PDF
LAB MANUAL
Prepared
By
G. Hema Kumar
Sr. Assistant Professor
Vision
⮚ To produce globally competitive and socially sensitized engineering graduates and to
bring out quality research in the frontier areas of Electronics & Communication
Engineering.
Mission
⮚ To provide quality and contemporary education in the domain of Electronics &
Communication Engineering through periodically updated curriculum, best of breed
laboratory facilities, collaborative ventures with the industries and effective teaching
learning process.
⮚ To pursue research and new technologies in Electronics & Communication
Engineering and related disciplines in order to serve the needs of the society, industry,
government and scientific community.
PEO1. Excel in their professional career and higher education in Electronics and
Communication Engineering and related fields
PSO1 Demonstrate proficiency in the use of IOT required in real life applications.
Implement functional blocks of hardware / software designs for signal processing and
PSO2
communication applications.
CODE OF CONDUCT FOR THE LABORATORIES:
1. All students must observe the dress Code while in the laboratory.
2. All bags must be left at the indicated place.
3. The lab timetable must be strictly followed.
4. Be PUNCTUAL for your laboratory session.
5. Workspace must be kept clean and tidy at all time.
6. Handle the systems and equipment with care.
7. All students are liable for any damage to the accessories due to their own negligence.
8. Students are strictly PROHIBITED from taking out any items from the laboratory.
9. Report immediately to the Lab Supervisor if any malfunction of the accessories, is
there.
10. Return the components/meters, turn off the system properly before leaving the lab.
20EC4351: SIGNALS AND SYSTEMS LAB
Course Category: Programme core Credits: 1.5
Course Type: Practical Lab Lecture - Tutorial -Practice: 0-0-3
Prerequisites: 20EC4101:Signals and Continuous Evaluation: 30
Systems Semester end Evaluation: 70
Total Marks: 100
Course Upon successful completion of the course, the student will be able to:
outcomes
CO1 Generate and perform the basic operations on continuous and discrete time
signals
CO2 Analyze the continuous and discrete time signals and systems using Fourier
Series and Fourier Transform
Contribution PO PO PO PO PO PO PO PO PO PO PO PO PSO PSO
of Course 1 2 3 4 5 6 7 8 9 10 11 12 1 2
Outcomes
towards 2 2
achievement CO1 2
of Program
Outcomes
(1 – Low, 2 - CO2 2 2 2
Medium, 3 –
High)
Course Perform the following using simulation software (Matlab/Labview/Scilab)
Content 1. Generation and plotting of Trigonometric and Exponential functions.
2. Generation of standard signals (Impulse, Unit step, Ramp, Sinc functions).
3. Operation on signals (Folding, time shifting, time scaling, amplitude scaling).
4. Generation of periodic and Non-periodic signals.
5. Analysis of Periodic signals using Fourier series.
6. Analysis of Non-periodic signals using Fourier Transform
7. Designing and Simulation of Transfer function.
8. Design of System and analysis by using poles and zeros
9. Verification of Sampling theorem
10. Write a program to find the correlation and convolution of sequences
Course-based Project
11. Implementation of a voiced/unvoiced classifier based on spectral analysis
12. Design of volume control with fade in and fade out
Text books 1. Alan Oppenheim, Signals and Systems, Prentice Hall, 2009.
and Reference 2. Simon Haykin, Signals and Systems, Wiley Publications,2007
books 3. John.G.Proakis, Contemporary Communication Systems, Cengage Learning, 2013.
E-resources 1. https://in.mathworks.com/academia/books/contemporary-communication-systems-
and other using-matlab-proakis.html
digital 2. https://web.stanford.edu/~boyd/ee102/
material 3. https://in.mathworks.com/academia/books/signals-and-systems-using-matlab-
chaparro.html
Experiment 1
Generation and Plotting of Trigonometric and Exponential Functions
Aim: To write a MATLAB Program to generate Trigonometric and Exponential signals
Software Required: MATLAB
Procedure:
● Open MATLAB Software
● Open new M-file
● Type the program
● Save in current directory
● Run the program
● For the output see command window or figure window.
Theory:
The first basic category presented is that of sinusoidal signals. This type of signal is of the
form 𝑥(𝑡) = 𝐴 𝑐𝑜𝑠(𝜔𝑡 + 𝜃), where 𝜔 is the angular frequency, given in 𝑟𝑎𝑑/𝑠, 𝐴 is the
amplitude of the sinusoidal signal, and 𝜃 is the phase (in radians). Sinusoidal signals are
periodic signals with fundamental period 𝑇 given by 𝑇 = 2𝜋/𝜔 𝑠𝑒𝑐. Finally, a useful
quantity is the frequency 𝑓 given in 𝐻𝑒𝑟𝑡𝑧. Frequency is defined by 𝑓 = 1/𝑇 or 𝑓 = 𝜔/2𝜋.
Trigonometric Functions
3
Cosine
Sine
2
1
Amplitude
-1
-2
-3
0 0.5 1 1.5 2 2.5 3
Time
Exponential Functions
25
Increasing
Decreasing
20
15
Amplitude
10
0
-2 -1 0 1 2 3 4 5
Time
Result:
In this experiment trigonometric and exponential signals have been generated using
MATLAB.
Procedure:
● Open MATLAB Software
● Open new M-file
● Type the program
● Save in current directory
● Run the program
● For the output see command window or figure window.
Theory:
In mathematics, the Dirac delta distribution (𝛿 distribution), also known as the unit impulse is
a generalized function, whose value is zero everywhere except at zero, and whose integral
over the entire real line is equal to one.
The Heaviside step function or unit step function is a discontinuous function whose
value is zero for negative arguments and one for positive arguments. It is an example of the
general class of step functions, all of which can be represented as linear combinations of
translations of this one.
The ramp function is a unary real function, whose graph is shaped like a ramp. It can
be expressed by numerous definitions, for example "0 for negative inputs, output equals input
for non-negative inputs".
𝑠𝑖𝑛(𝜋𝑥)
Sinc function is defined as 𝑠𝑖𝑛𝑐(𝑥) = 𝜋𝑥
.
Program:
clc;
clear all;
t=-5:0.01:5;
u=[t>=0]; % unit step
d=[t==0]; % unit impulse
r=t.*u; % ramp function
s=sin(pi*t)./(pi*t); % sinc function
subplot(221)
plot(t,u)
ylim([-0.1 1.1]); % Change axis for better appearance of
graph
xlabel('Time')
ylabel('Amplitude')
title('Unit Step')
subplot(222)
plot(t,d)
ylim([-0.1 1.1]);
xlabel('Time')
ylabel('Amplitude')
title('Unit Impulse')
subplot(223)
plot(t,r)
xlabel('Time')
ylabel('Amplitude')
title('Ramp Function')
subplot(224)
plot(t,s)
xlabel('Time')
ylabel('Amplitude')
title('Sinc Function')
Output:
Unit Step Unit Impulse
1 1
0.8 0.8
Amplitude
Amplitude
0.6 0.6
0.4 0.4
0.2 0.2
0 0
-5 0 5 -5 0 5
Time Time
Ramp Function Sinc Function
5 1
4
0.5
Amplitude
Amplitude
2
0
1
0 -0.5
-5 0 5 -5 0 5
Time Time
Result:
In this experiment various standard signals have been generated using MATLAB.
Procedure:
● Open MATLAB Software
● Open new M-file
● Type the program
● Save in current directory
● Run the program
● For the output see command window or figure window.
Theory:
Time reversal of signal is a very interesting operation applicable on both continuous and
discrete signals. Here in this case the vertical axis acts as the mirror, and the transformed
image obtained is exactly the mirror image of the parent signal. In this operation the signal
𝑥(𝑡) is folded around 𝑡 = 0 to obtain a folded sequence 𝑦(𝑡). It can be defined as 𝑦(𝑡) =
𝑥(−𝑡) where 𝑥(𝑡) is the original signal.
Time shift is given by 𝑦(𝑡) = 𝑥(𝑡 − 𝑡0 ). When the shift constant t0 is positive, the
effect is to move the signal 𝑥(𝑡) to the right by 𝑡0 . In other words, each point on the signal
𝑥(𝑡) now falls t0 later in time, so we call this transformation a time delay. Likewise, when it
is negative, we call it a time advance.
Time scaling is given by 𝑦(𝑡) = 𝑥(𝑎𝑡). When the scaling factor a is greater than 1,
the effect is to “squeeze” the signal toward 𝑡 = 0: an arbitrary point on 𝑥(𝑡) located at, say,
𝑡 = 𝑡1 , namely 𝑥(𝑡1 ), is now moved to the point 𝑡1′ = 𝑡1 /𝑎 on the resulting signal 𝑦(𝑡).
𝑦(𝑡1′ ) = 𝑥(𝑎𝑡1′ ) = 𝑥(𝑎𝑡1 /𝑎) = 𝑥(𝑡1 ). Since 𝑡1′ is closer to the vertical axis than 𝑡1 is, this is
called time compression. When the factor 𝑎 is between 0 and 1, we call it time expansion.
The process of rescaling the amplitude of a signal is known as amplitude scaling. In
the amplitude scaling operation on signals, the shape of the resulting signal remains same as
that of the original signal but the amplitude is altered. The amplitude scaling is given by
𝑦(𝑡) = 𝐴 𝑥(𝑡). Where, 𝐴 is a constant. If 𝐴 > 1, the signal is amplified and if 𝐴 < 1, the
signal is attenuated.
Program:
clc;
clear all;
close all;
t=-2:0.01:2;
x=(0<t&t<=1).*1+(1<t&t<=2).*(2-t);
a=input('Enter the time scaling factor:');
t0=input('Enter the time shift value:');
A=input('Enter the amplitude scaling factor:');
subplot(321)
plot(t,x)
xlabel('Time')
ylabel('Amplitude')
title('Original Signal')
ylim([-0.1 1.1])
subplot(322)
plot(-t,x)
xlabel('Time')
ylabel('Amplitude')
title('Time Reversal')
ylim([-0.1 1.1])
subplot(323)
plot(t/a,x)
xlabel('Time')
ylabel('Amplitude')
title('Time Scaling')
ylim([-0.1 1.1])
subplot(324)
plot(t+t0,x)
xlabel('Time')
ylabel('Amplitude')
title('Time Shifting')
ylim([-0.1 1.1])
subplot(325)
plot(t,A*x)
xlabel('Time')
ylabel('Amplitude')
title('Amplitude Scaling')
ylim([-0.1 1.1])
Output:
Enter the time scaling factor:2
Enter the time shift value:3
Enter the amplitude scaling factor:0.7
Amplitude
0.5 0.5
0 0
-2 -1 0 1 2 -2 -1 0 1 2
Time Time
Time Scaling Time Shifting
1 1
Amplitude
Amplitude
0.5 0.5
0 0
-1 -0.5 0 0.5 1 1 2 3 4 5
Time Time
Amplitude Scaling
1
Amplitude
0.5
0
-2 -1 0 1 2
Time
Result:
In this experiment various operations on signals have been performed using MATLAB.
Theory:
Continuous Time Periodic Signal:
If a signal has a specific pattern and repeats itself at a regular interval of time, it is said to be
periodic. An aperiodic or non-periodic signal, on the other hand, is one that does not repeat at
a regular interval of time.
A cycle is defined as the completion of a full pattern. A period is the length of time
(measured in seconds) it takes to complete one full cycle. The length of a period indicated by
T varies depending on the signal, but it is always the same for any periodic signal. The
frequency of one complete cycle is called fundamental frequency F, and its reciprocal is
called fundamental period, denoted by T.
A continuous time signal 𝑥(𝑡) is said to be periodic if and only if
𝑥(𝑡 + 𝑇) = 𝑥(𝑡) for − ∞ < 𝑡 < ∞
Where, T is a positive constant that represents the time period of the periodic signal.
The smallest value of the time period (T) which justifies the definition of the periodic signal
is known as fundamental time period of the signal and is denoted by (𝑇0). The angular
frequency is given by, 𝜔 = 2𝜋𝑓.
A discrete-time signal x(n) is said to be periodic if it satisfies the following condition
𝑥(𝑛) = 𝑥(𝑛 + 𝑁); for all integers 𝑛
where, N is the time period of the periodic signal and a positive integer. The smallest
value of the time period (N) which satisfies the above condition is known as fundament time
period of the signal. The fundamental time period (N) may be defined as the minimum
number of samples taken by signal to repeat itself. The angular frequency of the discrete time
periodic sequences is given by, 𝜔 = (2𝜋)/𝑁.
The sinusoid, square wave, triangle wave, and saw tooth wave are the most common
periodic signals.
Gate Function:
The value of the Gate function 𝑥(𝑡) is 0 for |𝑡| > 𝑇/2, and the value of the 𝑥(𝑡) is 𝐴
for |𝑡| < 𝑇/2.
The mathematical expression and graphical representation of Gate function are given
below:
𝐴, |𝑡| ≤ 𝑇/2 1 1
𝑥(𝑡) = { 𝑥(𝑡) = ∏(𝑡) = 𝑢 (𝑡 + 2) − 𝑢 (𝑡 − 2)
0, |𝑡| ≥ 𝑇/2
Signum function:
The signum function simply gives the sign for the given values of x. For x value greater
than zero, the value of the output is +1, for x value lesser than zero, the value of the output is
-1, and for x value equal to zero, the output is equal to zero. The mathematical expression and
graphical representation of signum function given below:
+1, 𝑥>0
𝑠𝑔𝑛(𝑥) = { 0, 𝑥=0
−1, 𝑥<0
Output:
Enter the amplitude of the square wave A = 2
Enter fundamental frequency of square wave F = 0.1
Enter the duty cycle of the wave DC = 50
Square Wave signal
4
1
Amplitude
-1
-2
-3
-4
-10 0 10 20 30 40 50
Time in seconds
Output:
Enter the amplitude of the sawtooth wave A = 2
Enter fundamental frequency of sawtooth wave F = 0.1
Enter maximum location with in each period W = 0.5
Sawtooth wave signal
4
2
Amplitude
-1
-2
-3
-4
-10 0 10 20 30 40 50
Time in seconds
Output:
Enter the amplitude of the Gate Function A = 2
Gate function
4
2
Amplitude
1
-1
-2
-3
-4
-20 -15 -10 -5 0 5 10 15 20
Time in seconds
1.5
1
Amplitude
0.5
-0.5
-1
-1.5
-2
-50 -40 -30 -20 -10 0 10 20 30 40 50
Time in seconds
Result:
The periodic and non-periodic signals are generated and plotted for the given amplitude and
fundamental frequency.
1. Give the mathematical notation that specifies the condition of periodicity for
continuous time signals?
2. What is duty cycle?
3. What is the time period of a periodic signal in actual terms?
4. What is the necessary and sufficient condition for a sum of a periodic continuous time
signal to be periodic?
5. What is the fundamental period of the signal x(t)= ejwt ?
6. The period of the signal x (t) = 10 sin 5t – 4 cos 9t is ?
7. Find the period of x(t) = cos(2t).
8. What is the period of sine signal?
9. Are all sinusoidal signals periodic?
10. Is the sum of two periodic signals is always periodic?
Experiment 5
Procedure:
Open MATLAB Software
Open new M-file
Type the program
Save in current directory
Run the program
For the output see command window or figure window.
Theory:
Fourier series a way of analyzing/decomposing a continuous-time signal into frequency
components given by sinusoidal signals. This process is crucial in the signal processing field
since it reveals the frequency content of a signal and simplifies the calculation of a system’s
output. With the use of the Fourier series, a signal is expressed in the frequency domain and
sometimes a frequency representation of a signal reveals more information about the signal
than its time domain representation. A signal 𝑥(𝑡) is periodic if 𝑥(𝑡) = 𝑥(𝑡 + 𝑇) for all
values of 𝑡. Any periodic signal, 𝑥(𝑡) can be represented by using complex exponential
Fourier series as
∞
𝑥(𝑡) = ∑ 𝑎𝑘 𝑒 𝑗𝑘𝜔0 𝑡
𝑘=−∞
𝑡0 +𝑇
1
𝑎𝑘 = ∫ 𝑥(𝑡) 𝑒 −𝑗𝑘𝜔0 𝑡
𝑇
𝑡0
Fourier spectrum of a periodic signal 𝑥(𝑡) can be obtained by plotting the Fourier
coefficients with respect to 𝑛. The plot of amplitude of the Fourier coefficients versus 𝑛
is known as amplitude spectrum and the plot of phase of Fourier coefficients verses 𝑛 is
known as phase spectrum. The two plots together are known as frequency spectrum of 𝑥(𝑡).
Program:
clc;
clear all;
close all;
syms t k
x=exp(-t/2);
T=3;
w=2*pi/T;
a=(1/T)*int(x*exp(-j*k*w*t),t,0,T);
k1=-10:10;
ak=subs(a,k,k1);
subplot(211)
stem(k1,abs(ak));
legend('|a_k|')
subplot(212)
stem(k1,angle(ak));
legend('\angle a_k')
Output:
Magnitude Spectrum
0.8
|ak|
0.6
0.4
0.2
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
Phase Spectrum
2
ak
1
-1
-2
-10 -8 -6 -4 -2 0 2 4 6 8 10
Program:
clc;
clear all;
close all;
syms t k
x=exp(-t/2);
T=3;
w=2*pi/T;
for k=-1:1
a(k+2)=(1/T)*int(x*exp(-j*k*w*t),t,0,T);
ex(k+2)=exp(j*k*w*t);
end
xx=sum(a.*ex);
figure(1)
ezplot(x,[0 T])
figure(2)
ezplot(xx, [0 T]);
title('Approximation with 3 terms')
for k=-50:50
a(k+51)=(1/T)*int(x*exp(-j*k*w*t),t,0,T);
ex(k+51)=exp(j*k*w*t);
end
xx=sum(a.*ex);
figure(3)
ezplot(xx, [0 T]);
title('Approximation with 101 terms')
Output:
exp(-t/2)
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.7
0.6
0.5
0.4
0.3
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0 0.5 1 1.5 2 2.5 3
t
Result:
In this experiment a periodic signal has been approximated by using Fourier series.
Procedure:
Theory:
A periodic signal defined for −∞ < 𝑡 < ∞ or a signal defined in a closed time interval
𝑎 ≤ 𝑡 ≤ 𝑏 can be expanded in a Fourier series, as a linear combination of infinite
sinusoidal signals. The Fourier series expansion reveals the frequency content of a signal.
The Fourier transform is the way to express any signal defined in the time domain for
−∞ < 𝑡 < ∞ in the frequency domain. The Fourier transform is denoted by the symbol
𝐹{. }; and is defined as
∞
In MATLAB there is the possibility to compute directly the Fourier transform 𝑋(𝜔) of a
signal 𝑥(𝑡) by using the command fourier. Correspondingly, the inverse Fourier transform
is computed by using the command ifourier. Before executing these two commands, time 𝑡
and frequency 𝜔 must be declared as symbolic variables.
𝟏
Exponential Function, 𝒙(𝒕) = 𝒆−𝒕 𝒖(𝒕), 𝑿(𝝎) = 𝟏+𝒋𝝎
Program:
clc;
clear all;
close all;
syms t w;
x=exp(-t)*heaviside(t);
F=fourier(x,w);
simplify(F)
figure(1)
ezplot(x,[-5 5])
ylim([-0.1 1.1])
legend('x(t)')
figure(2)
subplot(211)
ezplot(abs(F),[-5 5])
legend('|X(w)|')
subplot(212)
ezplot(angle(F),[-5 5])
legend('\angle X(w)')
Output:
ans =
1/(w*i + 1)
exp(-t) heaviside(t)
x(t)
1
0.8
0.6
0.4
0.2
-5 -4 -3 -2 -1 0 1 2 3 4 5
t
1/abs(w i + 1)
1
|X(w)|
0.8
0.6
0.4
0.2
-5 -4 -3 -2 -1 0 1 2 3 4 5
w
angle(1/(w i + 1))
X(w)
1
-1
-5 -4 -3 -2 -1 0 1 2 3 4 5
w
𝟏, |𝒕| < 𝟏
Gate Function, 𝒙(𝒕) = { , 𝑿(𝝎) = 𝟐 𝒔𝒊𝒏𝒄(𝝎)
𝟎, |𝒕| > 𝟏
Program:
clc;
clear all;
close all;
syms t w;
x=heaviside(t+1)-heaviside(t-1);
F=fourier(x,w);
simplify(F)
figure(1)
ezplot(x,[-5 5])
ylim([-0.1 1.1])
legend('x(t)')
figure(2)
subplot(211)
ezplot(abs(F),[-5 5])
legend('|X(w)|')
subplot(212)
ezplot(angle(F),[-10 10])
legend('\angle X(w)')
Output:
ans =
(2*sin(w))/w
heaviside(t + 1) - heaviside(t - 1)
x(t)
1
0.8
0.6
0.4
0.2
-5 -4 -3 -2 -1 0 1 2 3 4 5
t
2
|X(w)|
1.5
0.5
0
-5 -4 -3 -2 -1 0 1 2 3 4 5
w
angle((cos(w) i + sin(w))/w - (cos(w) i - sin(w))/w)
3 X(w)
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
w
−𝝎𝟐
−𝒕𝟐
Gaussian Function, 𝒙(𝒕) = 𝒆 , 𝑿(𝝎) = √𝝅 𝒆 𝟒
Program:
clc;
clear all;
close all;
syms t w;
x=exp(-t^2);
F=fourier(x,w);
simplify(F)
figure(1)
ezplot(x,[-5 5])
ylim([-0.1 1.1])
figure(2)
subplot(211)
ezplot(abs(F),[-10 10])
legend('|X(w)|')
subplot(212)
ezplot(angle(F),[-10 10])
legend('\angle X(w)')
Output:
ans =
pi^(1/2)*exp(-w^2/4)
exp(-t2)
0.8
0.6
0.4
0.2
-5 -4 -3 -2 -1 0 1 2 3 4 5
t
1/2 exp(-real(w2)/4)
|X(w)|
1.5
0.5
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
w
angle(exp(-w2/4))
1
X(w)
0.5
-0.5
-1
-10 -8 -6 -4 -2 0 2 4 6 8 10
w
𝟏 + 𝒕, −𝟏 ≤ 𝒕 ≤ 𝟎 𝝎
Triangular Function, 𝒙(𝒕) = { , 𝑿(𝝎) = 𝒔𝒊𝒏𝒄𝟐 ( 𝟐 )
𝟏 − 𝒕, 𝟎 ≤ 𝒕 ≤ 𝟏
Program:
clc;
clear all;
close all;
syms t w;
x=(t+1)*(heaviside(t+1)- heaviside(t))+(1-t)*(heaviside(t)-
heaviside(t-1));
F=fourier(x,w);
simplify(F)
F=int(x*exp(-j*w*t),t,-inf,inf)
figure(1)
ezplot(x,[-3 3])
legend('x(t)')
figure(2)
subplot(211)
ezplot(abs(F),[-20 20])
legend('|X(w)|')
subplot(212)
ezplot(angle(F),[-20 20])
legend('\angle X(w)')
Output:
ans =
-(2*cos(w) - 2)/w^2
F =
-(2*cos(w) - 2)/w^2
(t - 1) (heaviside(t - 1) - heaviside(t)) + (t + 1) (heaviside(t + 1) - heaviside(t))
1 x(t)
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
-3 -2 -1 0 1 2 3
t
0.5
0
-20 -15 -10 -5 0 5 10 15 20
w
angle(-(2 cos(w) - 2)/w2)
1
X(w)
0.5
-0.5
-1
-20 -15 -10 -5 0 5 10 15 20
w
Result:
In this experiment magnitude and phase spectrum of some functions have been plotted by
using Fourier transform.
Procedure:
● Open MATLAB Software
● Open new M-file
● Type the program
● Save in current directory
● Run the program
● For the output see command window or figure window.
Theory:
The transfer function of an LTI system is defined as the ratio of the Laplace transform
𝑌(𝑠) of the output signal 𝑦(𝑡) to the Laplace transform 𝑋(𝑠) of the input signal 𝑥(𝑡),
supposing zero initial conditions.
𝑦(𝑡) = ℎ(𝑡) ∗ 𝑥(𝑡)
Applying Laplace transform to both sides and considering the convolution property of
Laplace transform yields
𝑌(𝑠) = 𝑋(𝑠)𝐻(𝑠)
Where 𝐻(𝑠) is the transfer function. A transfer function is usually given in rational
form, written as a ratio of two polynomials.
In order to define a transfer function in MATLAB we can use the command tf. The
syntax is H=tf(num, den), where num and den are vectors containing the polynomial
coefficients of the numerator and denominator, respectively. The outcome H is a special type
of MATLAB variable named TF object, and represents the transfer function of a system.
If the system is stable, the frequency response 𝐻(𝑗𝜔) of the system is computed by
substituting 𝑠 by 𝑗𝜔 in 𝐻(𝑠). In order to numerically compute 𝐻(𝑗𝜔) over a frequency range
𝜔1 < 𝜔 < 𝜔2 rad/s from the system transfer function 𝐻(𝑠), one can use the command
freqresp. Its syntax is Hw=freqresp(Hs,w), where Hs denotes the transfer function
𝐻(𝑠) of the system, w is the vector containing the frequencies, and Hw is the frequency
response of the system evaluated at the frequencies specified in vector w. However, the
output argument Hw is a 3-D matrix. In the simple case of a SISO system, the value of the
frequency response for a specific frequency is contained in the third dimension of the 3-D
matrix Hw. Hence, in order to plot the magnitude of the computed frequency response the
appropriate statement is plot(w,angle(Hw(:,:)), and correspondingly the graph of
the phase is derived with the statement plot(w,angle(Hw(:,:))).
𝟐𝒔+𝟓
Program: 𝑯(𝒔) = (𝒔+𝟐)(𝒔+𝟑)
clc;
close all;
clear all;
syms s t
num=[2 5];
den=poly([-2 -3]);
Hs=tf(num,den)
w=-10:.1:10;
Hw=freqresp(Hs,w);
subplot(211)
plot(w,abs(Hw(:,:)));
legend('|H(w)|');
grid on;
subplot(212)
plot(w,angle(Hw(:,:)))
legend('\angle H(w)');
grid on;
Output:
H=
2s+5
-------------
s^2 + 5 s + 6
0.6
0.4
0.2
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
2
H(w)
1
-1
-2
-10 -8 -6 -4 -2 0 2 4 6 8 10
𝟐𝒔+𝟒
Program: 𝑯(𝒔) = (𝒔𝟐 +𝟒𝒔+𝟑)
clc;
close all;
clear all;
syms s t
num=[2 4];
den=[1 4 3];
Hs=tf(num, den)
w=-10:.1:10;
Hw=freqresp(Hs,w);
subplot(211)
plot(w,abs(Hw(:,:)));
legend('|H(w)|');
grid on;
subplot(212)
plot(w,angle(Hw(:,:)))
legend('\angle H(w)');
grid on;
Output:
H=
2s+4
-------------
s^2 + 4 s + 3
0.5
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
2
H(w)
1
-1
-2
-10 -8 -6 -4 -2 0 2 4 6 8 10
𝟏
Program: 𝑯(𝒔) =
(𝒔−𝟏)(𝒔+𝟐)
clc;
close all;
clear all;
syms s t
num=[1];
den=poly([1 -2]);
Hs=tf(num, den)
w=-10:.1:10;
Hw=freqresp(Hs,w);
subplot(211)
plot(w,abs(Hw(:,:)));
legend('|H(w)|');
grid on;
subplot(212)
plot(w,angle(Hw(:,:)))
legend('\angle H(w)');
grid on;
Output:
H=
-----------
s^2 + s - 2
Continuous-time transfer function.
0.5
|H(w)|
0.4
0.3
0.2
0.1
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
4
H(w)
2
-2
-4
-10 -8 -6 -4 -2 0 2 4 6 8 10
Result:
In this experiment frequency spectrum of given transfer function is plotted using MATLAB.
Procedure:
Open MATLAB Software
Open new Matlab script file
Type the program
Save in current directory
Run the program
For the output see command window / Figure window.
Theory:
Let 𝑦(𝑡) denote the response of a system 𝑇 to an input signal 𝑥(𝑡), that is,
𝑦(𝑡) = 𝑇{ 𝑥(𝑡)}. System T is linear if for any input signals 𝑥1 (𝑡) and 𝑥2 (𝑡) and any scalars
𝑎1 and 𝑎1 the following relationship holds:
In other words, the response of a linear system to an input that is a linear combination of two
signals is the linear combination of the responses of the system to each one of these signals.
The linearity property is generalized for any number of input signals, and this is often
referred to as the principle of superposition.
A system is time invariant, if a time shift in the input signal results in the same time shift in
the output signal. In other words, if 𝑦(𝑡) is the response of a time-invariant system to an input
signal 𝑥(𝑡), then the system response to the input signal 𝑥(𝑡 − 𝑡0 ) is 𝑦(𝑡 − 𝑡0 ). The
mathematical expression is
𝑦(𝑡 − 𝑡0 ) = 𝑇{ 𝑥(𝑡 − 𝑡0 )}
clc;
clear all;
close all;
t=-2:0.01:2;
a=2;
b=3;
w=2;
x1=5*cos(w*t);
y1=x1.*cos(4*w*t); %y(t)=x(t)cos(4wt)
x2=6*sin(w*t);
y2=x2.*cos(4*w*t);
x3=a*x1+b*x2;
y=x3.*cos(4*w*t);
z=a*y1+b*y2;
if (round(z)==round(y))
disp('The System is Linear');
else
disp('The System is non linear');
end;
subplot(4,2,1);
plot(t,x1);
title('x_1 function');
subplot(4,2,2);
plot(t,y1);
title('y_1 function');
subplot(4,2,3);
plot(t,x2);
title('x_2 function');
subplot(4,2,4);
plot(t,y2);
title('y_2 function');
subplot(4,2,5);
plot(t,x3);
title('x_3=ax_1+bx_2 function');
subplot(4,2,6);
plot(t,y);
title('Output due to sum of weighted inputs - (ax_1+bx_2)');
subplot(4,2,7);
plot(t,z);
title('Sum of Weighted outputs – ay_1+by_2 ');
Output:
clc;
clear all;
close all;
n=-4:4; %Length of the input signal
x=cos(n); % Input signal
y=n.*x; %y(n)=n*x(n)
xd=cos(n-3); % Input signal delayed by 3
ydi=n.*xd; % Output due to delayed input signal xd
ydo=(n-3).*xd; % Delayed Output
d=ydi-ydo; % Difference between y(t,d) and y(t-d)
if (d==0)
disp('Given system is Time invariant');
else
disp('Given system is NOT Time invariant');
end
subplot(3,2,1);
stem(n,x);
title('Input signal');
subplot(3,2,2);
stem(n,y);
title('Output signal');
subplot(3,2,3);
stem(n,xd);
title('Delayed input');
subplot(3,2,4);
stem(n,ydi);
title('Output due to Delayed input');
subplot(3,2,5);
stem(n,ydo);
title('Delayed output signal');
subplot(3,2,6);
stem(n,d);
title({'Difference between delayed output' ,'and output due to
delayed input'});
Output:
0 0
-1 -5
-4 -2 0 2 4 -4 -2 0 2 4
0 0
-1 -5
-4 -2 0 2 4 -4 -2 0 2 4
Difference between delayed output
Delayed output signal and output due to delayed input
10 5
0 0
-10 -5
-4 -2 0 2 4 -4 -2 0 2 4
Result:
In this experiment Linearity and Time invariance properties of given system has been
verified using MATLAB.
Procedure:
Theory:
Z-transform:
The Z-transform converts a discrete time-domain signal, which is a sequence of real or
complex numbers, into a complex frequency-domain representation. The Z-transform, like
many other integral transforms, can be defined as either a one-sided or two-sided transform.
Bilateral Z-transform
The bilateral or two-sided Z-transform of a discrete-time signal 𝑥[𝑛] is the function 𝑋(𝑧)
defined as
∞
Unilateral Z-transform
Alternatively, in cases where 𝑥[𝑛] is defined only for 𝑛 ≥ 0, the single-sided or
unilateral Z-transform is defined as
𝑋(𝑧) = 𝑍{𝑥[𝑛]} = ∑∞
𝑛=0 𝑥 [𝑛]𝑧
−𝑛
, 𝑤ℎ𝑒𝑟𝑒 𝑧 = 𝑟 ⋅ 𝑒 𝑗𝜔
𝑃(𝑧)
𝑋(𝑧) =
𝑄(𝑧)
Output:
Enter the Numerator Coefficients [1 2 3 4]
Enter the Denominator Coefficients [1 4 5 6]
H=
s^3 + 2 s^2 + 3 s + 4
---------------------
s^3 + 4 s^2 + 5 s + 6
1.5 0.92
1
Imaginary Axis (seconds-1)
0.98
0.5
-0.5
0.98
-1
-1.5 0.92
1.5
0.5
Imaginary Part
-0.5
-1
-1.5
Result:
In this experiment the poles and zeros are located and plotted in s-plane and z-plane for the
given transfer function using MATLAB.
Post Lab Questions:
1. Define Stability?
2. What are poles and zeros?
3. What is invertible system?
4. What is ITR and FIR system?
5. What do you mean by BIBO condition?
Experiment-9
Theory:
Sampling is the process of converting a continuous time signal 𝑔(𝑡) into a discrete time
signal 𝑔(𝑛) by measuring the amplitudes of continuous time signal 𝑔(𝑡) at integer
multiples of a sampling interval 𝑇𝑠 .
Sampling theorem states that a band limited signal can be reconstructed exactly
if it is sampled at a rate at least twice the maximum frequency component in it. Figure
shows a signal 𝑔(𝑡) that is band limited to 𝜔𝑚 .
The maximum frequency component of 𝑔(𝑡) is 𝑓𝑚 . To recover the signal 𝑔(𝑡) exactly
from its samples it has to be sampled at a rate 𝑓𝑠 ≥ 2𝑓𝑚 . The minimum required sampling
rate 𝑓𝑠 = 2𝑓𝑚 is called ' Nyquist rate and 𝑇𝑠 = 1/2𝑓𝑚 is called Nyquist interval.
Program:
clc;
clear all;
close all;
% Signal Parameters
fm = 10; % Signal Frequency = 10Hz
T = 1/fm; % Signal Period
t = 0:0.01*T:2*T; % Time index
% Generate the original signal and plot it:
x = cos(2*pi*fm*t); % Signal : 2*pi*f*t
subplot(2,2,1);
plot(t,x);
title('Continuous signal');
xlabel('t');
ylabel('x(t)');
%Oversampling Condition:
fs1 = 10*fm; % Oversampling (fs > 2fm)
n1 = 0:1/fs1:2*T; % Time scale (nTs)
x1 = cos(2*pi*fm*n1); % Generating sampled signal
subplot(2,2,2);
stem(n1,x1);
hold on;
plot(n1,x1,'r');
title('Oversampling Condition: f_s = 10f_m');
xlabel('n');
ylabel('x(n)');
% Right Sampling Condition:
fs2 = 2*fm; % Nyquist Rate Sampling (fs = 2fm)
n2 = 0:1/fs2:2*T; % Time scale (nTs)
x2 = cos(2*pi*fm*n2);
subplot(2,2,3);
stem(n2,x2);
hold on;
plot(n2,x2,'r');
title('Sampling at Nyquist Frequency: f_s = 2f_m');
xlabel('n');
ylabel('x(n)');
% Under Sampling Condition:
fs3 = 1.5*fm; % Undersampling (fs < 2fm)
n3 = 0:1/fs3:2*T; % Time scale (nTs)
x3 = cos(2*pi*fm*n3);
subplot(2,2,4);
stem(n3,x3);
hold on;
plot(n3,x3,'r');
title('Undersampling Condition: f_s = 1.5f_m');
xlabel('n');
ylabel('x(n)');
legend('Sampled Signal','Recovered Signal')
Output:
0.5 0.5
x(n)
x(t)
0 0
-0.5 -0.5
-1 -1
0 0.05 0.1 0.15 0.2 0 0.05 0.1 0.15 0.2
t n
Sampling at Nyquist Frequency: fs = 2fm Undersampling Condition: fs = 1.5fm
1 1
Sampled Signal
0.5 0.5 Recovered Signal
x(n)
x(n)
0 0
-0.5 -0.5
-1 -1
0 0.05 0.1 0.15 0.2 0 0.05 0.1 0.15 0.2
n n
Result:
In this experiment the sampling theorem has been verified by using MATLAB.
Procedure:
Open MATLAB Software
Open new M-file
Type the program
Save in current directory
Run the program
For the output see command window or figure window.
Theory:
If length of the sequence 𝑥(𝑛) is 𝑁 and length of the sequence ℎ(𝑛) is 𝑀, then 𝑦(𝑛)
will have a length of 𝑀 + 𝑁 − 1. If the nonzero values of 𝑥(𝑛) are in the interval [𝑎𝑥 , 𝑏𝑥 ]
and the nonzero values of ℎ(𝑛) are in the interval [𝑎ℎ , 𝑏ℎ ] then the nonzero values of the
output 𝑦(𝑛) are in the interval [𝑎𝑥 + 𝑎ℎ , 𝑏𝑥 + 𝑏ℎ ]
The cross correlation function between two different signals is defined as the measure
of similarity between one signal and the time delayed version of another signal. The cross
correlation between two sequences 𝑥(𝑛) and 𝑦(𝑛) is given by
The auto correlation of a sequence is correlation of a sequence with itself. The auto
correlation of sequence 𝑥(𝑛) is defined as
If length of the sequence 𝑥(𝑛) is 𝑁 and length of the sequence 𝑦(𝑛) is 𝑀, then 𝑟𝑥𝑦 (𝑙) will
have a length of 2 × 𝑀𝑎𝑥(𝑀, 𝑁) − 1.
Program:
clc;
close all;
clear all;
x = input('Enter Input Sequence for Signal x(n): ');
h = input('Enter Input Sequence for Signal h(n): ');
[c,lags] = xcorr(x,h); %Performing correlation
y=conv(x,h); %Performing Convolution using conv command
disp('Convolved sequence using matlab function:');
disp(y);
n1=length(x);
n2=length(h);
N = n1+n2-1; %Length of Convolved Sequence
%Zero padding to make sequences of length N
x=[x zeros(1,N-n1)];
h=[h zeros(1,N-n2)];
%Initializing the output with zeros
y = zeros(1,N);
%Performing Convolution using formula
for n = 1:N
for k = 1:n
y(n)=y(n)+x(k)*h(n-k+1);
end
end
disp('Convolved sequence using convolution sum formula:');
disp(y);
subplot(2,2,1);
stem(0:N-1,x);
title('Input Sequence x(n)');
xlabel('n');
ylabel('x(n)');
subplot(2,2,2);
stem(0:N-1,h);
title('Input Sequence h(n)');
xlabel('n');
ylabel('h(n)');
subplot(2,2,3);
stem(lags,c);
title('Correlation of x(n) and h(n)');
subplot(2,2,4);
stem(0:N-1,y);
title('Convolution of x(n) and h(n)');
Output:
Enter Input Sequence for Signal x(n): [1 2 3]
Enter Input Sequence for Signal h(n): [4 5]
Convolved sequence using matlab function:
4 13 22 15
Convolved sequence using convolution sum formula:
4 13 22 15
2 4
x(n)
h(n)
1 2
0 0
0 1 2 3 0 1 2 3
n n
Correlation of x(n) and h(n) Convolution of x(n) and h(n)
30 30
20 20
10 10
0 0
-2 -1 0 1 2 0 1 2 3
Result:
In this experiment convolution and correlation of two sequences have been obtained using
MATLAB.