0% found this document useful (0 votes)
5 views

BEC 453_signals & systems lab manual

The document is a lab manual for the Signal System Lab (KEC 453) prepared by the Electronics and Communication Engineering department at Ajay Kumar Garg Engineering College. It includes a list of experiments focused on MATLAB applications, such as plotting signals, performing transformations, and analyzing system responses. The manual also outlines course outcomes and mappings to program outcomes, ensuring alignment with academic standards.

Uploaded by

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

BEC 453_signals & systems lab manual

The document is a lab manual for the Signal System Lab (KEC 453) prepared by the Electronics and Communication Engineering department at Ajay Kumar Garg Engineering College. It includes a list of experiments focused on MATLAB applications, such as plotting signals, performing transformations, and analyzing system responses. The manual also outlines course outcomes and mappings to program outcomes, ensuring alignment with academic standards.

Uploaded by

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

DEPARTMENT

ELECTRONICS AND COMMUNICATION


ENGINEERING

LAB MANUAL

SIGNAL SYSTEM LAB


(KEC 453)
Department
Of
Electronics and Communication Engineering

LAB MANUAL

SIGNAL SYSTEM LAB

KEC 453

Prepared by: Signature:


Dushyant Singh Chauhan Dr. P. K. Chopra
Asst. Prof. Prof. & HoD
ECE Department ECE Department
Ajay Kumar Garg Engineering College, Ghaziabad
Department of ECE
Lab Name with Lab Code: SIGNAL SYSTEM LAB (KEC-453)

SUGGESTIVE LIST OF EXPERIMENTS AS PER AKTU

1. Introduction to MATLAB

a. To define and use variables and functions in MATLAB.

b. To define and use Vectors and Matrices in MATLAB.

c. To study various MATLAB arithmetic operators and mathematical functions.

d. To create and use m-files.

2. Basic plotting of signals

a. To study various MATLAB commands for creating two- and three-dimensional plots.

b. Write a MATLAB program to plot the following continuous time and discrete time signals.

i. Step Function

ii. Impulse Function

iii. Exponential Function

iv. Ramp Function

v. Sine Function

3. Time and Amplitude Transformations Write a MATLAB program to perform amplitude-scaling,

time-scaling and time shifting on a given signal.

4. Convolution of given signals Write a MATLAB program to obtain linear convolution of the

given sequences.

5. Autocorrelation and Cross-correlation

a. Write a MATLAB program to compute autocorrelation of a sequence x(n) and verify the

property.

iii
b. Write a MATLAB program to compute cross-correlation of sequences x(n) and y(n) and

verify the property.

6. Calculating transforms using MATLAB

a. Calculate and plot Fourier transform of a given signal.

b. Calculate and plot Z-transform of a given signal.

7. Impulse response and Step response of a given system

a. Write a MATLAB program to find the impulse response and step response of a system

form its difference equation.

b. Compute and plot the response of a given system to a given input.

8. Pole-zero diagram and bode diagram

a. Write a MATLAB program to find pole-zero diagram, bode diagram of a given system

from the given system function.

b. Write a MATLAB program to find, bode diagram of a given system from the given

system function.

9. Frequency response of a system Write a MATLAB program to plot magnitude and phase

response of a given system.

10. Checking linearity/non-linearity of a system using SIMULINK

a. Build a system that amplifies a sine wave by a factor of two.

b. Test the linearity of this system using SIMULINK.

Additional Experiments:

S.No. Experiment Title Relevance to CO Relevance to POs

1. Verification of sampling theorem using CO1 PO1-PO5, PO12,


MATLAB. PSO1, PSO2

2. Implementation of decimation and CO3 PO1-PO5, PO12,


interpolation processes using PSO1, PSO2
MATLAB.

iv
Course Outcomes as per the AKTU Syllabus

CO1. Demonstrate the basics operation of MATLAB.


CO2. Analyse the time domain and frequency domain signals.
CO3. Implement the concept of Fourier series and Fourier transforms.
CO4. Find the stability of system using pole-zero diagrams and bode diagram.
CO5. Design frequency response of the system.

Updated Course Outcomes after Including Additional Experiments:

CO1. Demonstrate the basics operation of MATLAB.


CO2. Analyze the time domain and frequency domain signals.
CO3. Implement the concept of Fourier series and Fourier transforms.
CO4. Find the stability of system using pole-zero diagrams and bode diagram.
CO5. Design frequency response of the system.
CO6. Verify the sampling theorem using MATLAB Simulations.
CO7. Implement decimation and interpolation processes using MATLAB.

Final CO-PO/PSO Mapping

PO1 PO2 PO3 PO4 PO5 PO12 PSO1 PSO2


PO6 PO7 PO8 PO9 PO10 PO11
(2) (2) (3) (2) (2) (1) (2) (3)

CO1 3 3 2 3 3 3 3 2

CO2 3 3 2 3 3 3 3 2

CO3 3 3 2 3 3 3 3 2

CO4 3 3 2 3 3 3 3 2

CO5 3 3 3 3 3 3 3 3

CO6 3 3 2 3 3 3 3 2

CO7 3 3 3 3 3 3 3 3

Mr. Dushyant Singh Dr. Jitender Chhabra

Lab Faculty NBA Coordinator HoD, ECE

v
Index
S.No Experiment Page. No

1 Introduction to MATLAB 1

2 Basic plotting of signals 3

3 Time and Amplitude Transformations Write a MATLAB 7


program to perform amplitude-scaling, time-scaling and time
shifting on a given signal
4 Convolution of given signals Write a MATLAB program to 11
obtain linear convolution of the given sequences
5 Autocorrelation and Cross-correlation 13

6 Calculating transforms using MATLAB 15

7 Impulse response and Step response of a given system 18

8 Pole-zero diagram and bode diagram 21

9 Frequency response of a system Write a MATLAB program to 24


plot magnitude and phase response of a given system
10 Checking linearity/non-linearity of a system using SIMULINK 26

11 Verification of sampling theorem using MATLAB 28

12 Implementation of decimation and interpolation processes using 31


MATLAB

vi
EXPERIMENT NO - 1
OBJECTIVE: Introduction to MATLAB
a. To define and use variables and functions in MATLAB.
b. To define and use Vectors and Matrices in MATLAB.
c. To study various MATLAB arithmetic operators and mathematical functions.
d. To create and use m-files.

TOOL REQUIREMENT: MATLAB

THEORY: The name MATLAB stands for MATrix LABoratory. MATLAB is a high-
performance language for technical computing.
The variables are created with an assignment statement. The syntax of variable assignment is
Variable name = a value (or an expression).
Matrices are the basic elements of the MATLAB environment. A matrix is a two-dimensional
array consisting of m rows and n columns. Special cases are column vectors (n = 1) and row
vectors (m = 1). All of the data that we enter into MATLAB is stored in the form of a matrix.
Various mathematical functions defined in MATLAB are

Various arithmetic operators are used in MATLAB


‘+’ for addition
‘-’ for subtraction
‘*’ for multiplication
‘/’ for division
‘^’ for raising an expression to a power
An m-file, or script file, is a simple text file where you can place MATLAB commands. When
the file is run, MATLAB reads the commands and executes them exactly as it would if you had
typed each command sequentially at the MATLAB command window. All m-file names must
end with the extension '.m' (e.g. test.m).
the function can be defined as
function output_varible = name_of_function(input_varible).

1
% is used for comment line in MATLAB.

MATLAB CODE:
clc;
close all;
clear all;
Variable assignment:
a=5; % Scalar
a= [1 2 3] or [1,2,3] or a= 1:3 ; % Row vector
a= [1;2;3] ; % Column vector
a=[1 2 3; 4 5 6; 7 8 9] ; % Matrix
Arithmatic operation:
a=5 ; b=4;
c=a+b ;
c=a-b ;
c=a*b ;
c=a^b ;
c=a/b ;
Mathematical function
t = 0:pi/100:2*pi ;
y = sin(t) ;
plot(t,y) % plot the y versus t

RESULT: Various mathematical operations, function plotting, matrix initialization are


performed.

2
EXPERIMENT NO - 2

OBJECTIVE: Basic plotting of signals


a. To study various MATLAB commands for creating two- and three-dimensional plots.
b. Write a MATLAB program to plot the following Continuous time and discrete time
signals
1. Step Function
2. Impulse Function
3. Exponential Function
4. Ramp Function
5. Sine Function

TOOL REQUIREMENT: MATLAB

THEORY:
Discrete – Time signals
• Unit impulse sequence.
1, for n = 0
x ( n) =  ( n) = 
0, otherwise
• Unit step sequence.
1, for n  0
x ( n ) = u( n ) = 
• Unit ramp sequence. 0, otherwise
n, for n  0
x ( n) = r ( n) = 
• Sinusoidal sequence 0, otherwise
x(n) = A sin(n +  )
• Exponential sequence x(n) = A an, where A and a are constant.

Continuous – time signals:

1, for t = 0
• Unit impulse signal x (t ) =.  (t ) = 
(Ar
0, otherwise

1, for t  0
• Unit step signal. x (t ) = u(t ) = 
0, otherwise

• Unit ramp signal.


t , for t  0
x (t ) = r (t ) = 
0, otherwise
=
• Sinusoidal signal. x(t ) A (t
sin +  ).
( 
3
at
• Exponential signal. x ( t ) = A e , where A and a are constant.
Matlab commands for plotting: a
1. plot: for 2-D line plot
plot(X,Y)
a. Creates a 2-D line plot of the data in Y versus the corresponding values
in X.
b. If X and Y are both vectors, then they must have equal length. The plot
function plots Y versus X.
c. If X and Y are both matrices, then they must have equal size. The plot
function plots columns of Y versus columns of X.
2. Plot3: for 3-D line plot
plot3(x,y,z) x,y,z : same vector length
3. subplot: subplot create axes in tiled positions.
subplot(m,n,p): breaks the Figure window into an m-by-n matrix of small axes, selects
the p-th axes for the current plot, and returns the axis handle. The axes are counted along
the top row of the Figure window, then the second row, etc.
4. stem: for plotting discrete sequence data
stem(X,Y) :plots the data sequence, Y, at values specified by X. The X and Y
inputs must be vectors or matrices of the same size.
5. ones:
ones(N) is an N-by-N matrix of ones.
ones (M,N) or ones ([M,N]) is an M-by-N matrix of ones.

6. zeros:
zeros (N) is an N-by-N matrix of Zeros.
zeros (M,N) or zeros ([M,N]) is an M-by-N matrix of zeros

MATLAB CODE:
clc;
clear all;
close all;
t1=-3:1:3;
x1=[0,0,0,1,0,0,0];
subplot(3,3,1);
stem(t1,x1);
xlabel('time');
ylabel('Amplitude');
title('Unit impulse signal');
%UNIT STEP SIGNAL
t2=-5:1:25;
x2=[zeros(1,5),ones(1,26)];
subplot(3,3,2);
plot(t2,x2);

4
xlabel('time');
ylabel('Amplitude');
title('CT Unit step signal');

subplot(3,3,3);
stem(t2,x2);
xlabel('time');
ylabel('Amplitude');
title('DT Unit step signal');
%UNIT RAMP SIGNAL
t4=-10:1:20;
x4= [zeros(1,10),0:20];
subplot(3,3,4);
plot(t4,x4);
xlabel('time');
ylabel('Amplitude');
title('CT Unit ramp signal');

subplot(3,3,5)
stem(t4,x4);
xlabel('time');
ylabel('Amplitude');
title('DT Unit ramp signal');

%EXPONENTIAL SIGNAL
a= 4;
t3=-1:0.1:2;
x3=exp(-1*a*t3);
subplot(3,3,6);
plot(t3,x3);
xlabel('time');
ylabel('Amplitude');
title('CT Exponential signal');

subplot(3,3,7);
plot(t3,x3);
xlabel('time');
ylabel('Amplitude');
title('DT Exponential signal');

%SINUSOIDAL SIGNAL
A=4;
f=5;
t5=-1:0.01:1;
x5=A*sin(2*pi*f*t5);

5
subplot(3,3,8);
plot(t5,x5)
xlabel('time');
ylabel('Amplitude');
title('CT Sinusoidal signal');
subplot(3,3,9);
stem(t5,x5)
xlabel('time');
ylabel('Amplitude');
title('DT Sinusoidal signal');

RESULT: 2-D and 3-D plotting are performed. Continuous time domain and Discrete time
signals are plotted.

OUTPUT:

6
EXPERIMENT NO - 3
OBJECTIVE: Time and Amplitude transformations
a. Write a MATLAB program to perform amplitude-scaling, time-scaling and time-shifting
on a given signal.

TOOL REQUIREMENT: MATLAB

THEORY: Amplitude-Scaling of Signal: There are some important properties of signal such as
amplitude-scaling, time-scaling and time-shifting. Consider a signal x(t) which is multiplying by
a constant 'A' and this can be indicated by a notation x(t) → Ax(t). This is called amplitude-
scaling. If the amplitude-scaling factor is negative then it flips the signal with the t-axis as the
rotation axis of the flip. If the scaling factor is -1 then only the signal will be flip. This is shown
in the figures given below:

Time-Scaling of Signal: Time scaling compresses or expand a signal by multiplying the time
variable by some quantity. If that quantity is greater than one, the signal becomes narrower and
the operation is called compression. If that quantity is less than one, the signal becomes wider
and the operation is called expansion. Below figure shows the signal x(t), compression of signal
and expansion of signal respectively.

Time-Shifting of Signal: If a continuous time signal is defined as x(t) = s(t - t1). Then we can say
that x(t) is the time shifted version of s(t). Consider a simple signal s(t) for 0 < t < 1

7
Signal within 0< t < 1 Signal shifted by 2 sec. Signal shifted by -1 sec.

MATLAB CODE:
1. Amplitude Scaling
clc
clear all
close all
t = [-4:5];
y = [0, 2,3,1,4,1,2,2,3,0];

plot(t,y);
y1 = y * -1;
y2 = y * 0.5;
y3 = y * 3;

subplot(2,2,1);
plot(t,y);
xlabel('Time');
ylabel('y(t)');
grid on

subplot(2,2,2);
plot(t,y1);
xlabel('Time');
ylabel('{y_1}(t)');
grid on

subplot(2,2,3);
plot(t,y2);
xlabel('Time');
ylabel('{y_2}(t)');
grid on

subplot(2,2,4);
plot(t,y3);
xlabel('Time');
ylabel('{y_3}(t)');

8
grid on

sgtitle('Amplitude Scaling')

2. Time Scaling
clc
clear all
close all
t = -1:0.01:1;
y = sin(2*pi*1*t);
subplot(2,2,1);
plot(t,y);
xlabel('Time');
ylabel('y(t)');
grid on

subplot(2,2,2);
plot(t/2,y);
xlabel('Time');
ylabel('y(t/2)');
grid on

subplot(2,2,3);
plot(t*2,y);
xlabel('Time');
ylabel('y(2t)');
grid on

subplot(2,2,4);
plot(t*10,y);
xlabel('Time');
ylabel('y(10t)');
grid on

sgtitle('Time Scaling')

3. Time Shifting
RESULT: Effects of amplitude scaling, time scaling and time shifting has been observed. This
helps to understand how signal can be modify using mathematical operations.

OUTPUT:

9
10
EXPERIMENT NO - 4
OBJECTIVE: Convolution of given signals
Write a MATLAB program to obtain linear convolution of the given sequences.

TOOL REQUIREMENT: MATLAB

THEORY: Linear convolution is the basic operation to calculate the output for any linear time
invariant system given its input and its impulse response. If the response of the system to the
impulse signal is known,then the response to any other input to the system can be found out by
convolving the input signal with impulse response.

MATLAB CODE:
clc;
clear all;
close all;
n=0:8;
x1=1;
x2=0;
y1=x1.*(n>=0 & n<=2)+x2.*(n>=2 & n<=8);
subplot(2,2,1);
stem(n,y1);
axis([0 8 0 1.5]);
xlabel('Time n ---->');
ylabel('Amplitude---->');
title('Sequence {y_1}[n]')
y2=x1.*(n>=0 & n<=4)+x2.*(n>=4 & n<=8);
subplot(2,2,2);

11
stem(n,y2);
axis([0 8 0 1.5]);
xlabel('Time n ---->');
ylabel('Amplitude---->');
title('Sequence {y_2}[n]')
y=conv(y1,y2);
L=length(y);
n=0:L-1;
subplot(2,2,[3,4]);
stem(n,y);
axis([0 10 0 4]);
xlabel('Time n ---->');
ylabel('Amplitude---->');
title('Convolved sequence of {y_1}[n] & {y_2}[n]');

RESULT: Convolution of two discrete sequence has been performed using MATLAB and it can
be observed that length of output sequence is addition of two input sequence minus one.

OUTPUT:

12
EXPERIMENT NO - 5
OBJECTIVE: Autocorrelation and Cross-correlation
a. Write a MATLAB program to compute autocorrelation of a sequence x(n) and
verify the property.
b. Write a MATLAB program to compute cross-correlation of sequences x(n) and
y(n) and verify the property.

TOOL REQUIREMENT: MATLAB

THEORY: Correlation is a measure of similarity between two signals. For given discrete-time
real sequence x[k]. The autocorrelation function is defined by following equation:

Where the parameter k is any integer, -∞<k<∞

Using the definition for the total discrete-time signal energy, we see that for k=0, the
autocorrelation function represents the total signal energy that is:

Naturally, the autocorrelation sum is convergent under assumptions that the signal x[k] have
finite total energy. In addition, it is easy to show that the autocorrelation function is an even
function, that is

Hence, the autocorrelation function is symmetric with respect to the vertical axis.

MATLAB CODE:

% Autocorrelation
fs = 2000;
t1 = 0 : 1/fs : 0.2; % for 200 milliseconds
x = sin(2*pi*100*t1) + sin(2*pi*200*t1);
subplot(2,1,1);
plot(t1*1000,x);
xlabel('Time(milliseconds)');

13
ylabel('Amplitude');
title('Input Signal');
[acf lag] = xcorr(x); % k=lag = 2*N-1 (length)
subplot(2,1,2);
plot(lag/(fs/1000),acf);
xlabel('Lag in milliseconds');
ylabel('Amplitude');
title('Autocorrelation of above signal');

RESULT: It can be easily deduced that autocorrelation of given function is even function and
symmetry about y axis. It can also be observe that at k=0 (lag =0) value of autocorrelation
function is maximum and proportional to energy of given sequence x[n].

OUTPUT:

14
EXPERIMENT NO - 6
OBJECTIVE: Calculating transforms using MATLAB
a. Calculate and plot Fourier Transform of a given signal.
b. Calculate and plot Z-transform of a given signal.

TOOL REQUIREMENT: MATLAB

THEORY: A fast Fourier transform (FFT) algorithm computes the discrete Fourier transform
(DFT) of a sequence, or its inverse (IFFT). Fourier analysis converts a signal from its original
domain (often time or space) to a representation in the frequency domain and vice versa. An FFT
rapidly computes such transformations by factorizing the DFT matrix into a product of sparse
(mostly zero) factors. As a result, it manages to reduce the complexity of computing the DFT
from O(n2), which arises if one simply applies the definition of DFT, to O(n log(n)), where n is
the data size.

Z transform enables analysis of the signal in the frequency domain. It takes the form of a
polynomial and interpretation of the signal in terms of the roots of the polynomial. z-1
corresponds to a delay of one unit in the signal.

The Z - Transform of a discrete time signal x[n] is defined as

where z = r ejw
MATLAB CODE:

%FFT of given Signal


sampling_freq=1000;
t=0:1/sampling_freq:0.5; % 0.5 Seconds
x = sin(2*pi*100*t) + 0.5*sin(2*pi*200*t) + sin(2*pi*300*t);

subplot(2,1,1);

15
plot(t*1000,x);
xlabel('t (milliseconds)');
ylabel('x(t)');
title('Signal in Time Domain');

y=fft(x,500);
mag1 = abs(y);
mag1 = mag1(1:250);
k=[0:length(mag1)-1];
k=k*(sampling_freq/length(y));
subplot(2,1,2);
plot(k,mag1);
xlabel('Frequency(Hz)');
ylabel('Power');
title('FFT of x(t)');

%Z transform of finite sequence


function y = ztransform(x);
syms z y;
y=0;
for n=1:length(x)
y = x(n)*power(z,-(n-1)) + y;
end
end

RESULT: Given signal was analyzed using FFT algorithm and observed that frequency
components of can be analyzed efficiently. Z-transform of finite sequence is calculated.

OUTPUT:

1. Fourier Transform

16
2. Z-Transform

17
EXPERIMENT NO - 7
OBJECTIVE: Impulse response and Step response of a given system
a. Write a MATLAB program to find the impulse response and step response
of a system form its difference equation.
b. Compute and plot the response of a given system to a given input.

TOOL REQUIREMENT: MATLAB

THEORY: The response of a discrete-time system to a unit sample sequence {δ[n]} is called the
unit sample response or simply, the impulse response, and is denoted by {h[n]}

x[n]= δ[n] y[n]= h[n]


LTI system

Now H(s) = Laplace Transform of h(t) and H(z) = Z-transform of h[n]

The response of a discrete-time system to a unit step sequence {u[n]} is called the unit step
response or simply, the step response, and is denoted by {s[n]}

x[n]= u[n] y[n]= s[n]


LTI system

MATLAB CODE:

% Impulse response and step response of a system


clc;
clear all;
close all;
syms s complex;
H=1/(s^2+4*s+3);
disp('Impulse response of the system h(t) is');
h=ilaplace(H);
simplify(h);
disp(h);
Y=1/(s*(s^2+4*s+3));
disp('Step response of the system is');
y=ilaplace(Y);
simplify(y);
disp(y);

18
t=0:0.1:20;
h1=subs(h,t);
figure(1)
subplot(2,1,1);
plot(t,h1);
xlabel('Time');
ylabel('h(t)');
title('Impulse response of the system');
y1=subs(y,t);
subplot(2,1,2);
plot(t,y1);
xlabel('Time');
ylabel('x(t)');
title('Step response of the system');
% The response of a given system to a given input
n=[1 5 ];
d= [1 2 3 5];
t=0:0.15:9;
r=exp(-0.2*t);
y=lsim(n,d,r,t);
figure(2)
plot(t,r,t,y);
title ('System response of given transfer function for ramp input');
xlabel('Time(secs)');
ylabel('Amplitude');

RESULT: Impulse response of a system is = exp (-2*t)*sinh (t).


The step response of a system is = 1/6*exp (-3*t)-1/2*exp (-t) +1/3.
The plot of the system response of given transfer function for r input is completed.

19
OUTPUT:

20
EXPERIMENT NO - 8
OBJECTIVE: Pole-zero diagram and bode diagram
a. Write a MATLAB program to find pole-zero diagram of a given system from
the given system function.
b. Write a MATLAB program to find bode diagram of a given system from the
given system function.

TOOL REQUIREMENT: MATLAB

THEORY: A system is often defined in terms of the poles and zeros of its transfer function.
A system can be defined by its transfer function, which is a ratio of polynomials in the Laplace
variable "s." For example consider the transfer function:

In this equation the constant k=b0/a0. The zi terms are the zeros of the transfer function; as
s→zi the numerator polynomial goes to zero, so the transfer function also goes to zero. The
pi terms are the poles of the transfer function; as s→pi the denominator polynomial is zero, so the
transfer function goes to infinity.

MATLAB CODE:
% pole-zero diagram
clc;
clear all;
close all;
num=input('enter the numerator polynomial vector\n'); % [1 -2 1]
den=input('enter the denominator polynomial vector\n'); % [1 6 11 6]
H=tf(num,den)
[p z]=pzmap(H);
disp('zeros are at ');
disp(z);
disp('poles are at ');
disp(p);
pzmap(H);
if max(real(p))>=0
disp(' All the poles do not lie in the left half of S-plane ');
disp(' Given LTI systen is not a stable system ');

21
else
disp('All the poles lie in the left half of S-plane ');
disp(' Given LTI systen is a stable system ');
end;

% Bode diagram of s + 12 /2 s2 + s + 4
clc
clear all
num=[1, 12];
den=[2, 1, 4];
system=tf(num,den)
bode(system)

RESULT: Pole-Zero plot and bode plot of given system function is drawn.

OUTPUT:

Enter the numerator polynomial vector


[1 -2 1]
Enter the denominator polynomial vector
[1 6 11 6]

Transfer function:
s^2 - 2 s + 1
----------------------
s^3 + 6 s^2 + 11 s + 6

Zeros are at
1
1

Poles are at
-3.0000
-2.0000
-1.0000
All the poles lie in the left half of S-plane. The given LTI system is a stable system

22
23
EXPERIMENT NO - 9
OBJECTIVE: Frequency response of a system
a. Write a MATLAB program to plot magnitude and phase response of a given
system.

TOOL REQUIREMENT: MATLAB

THEORY: Frequency response is the quantitative measure of the output spectrum of a system or
device in response to a stimulus, and is used to characterize the dynamics of the system. It is a
measure of magnitude and phase of the output as a function of frequency, in comparison to the
input. In simplest terms, if a sine wave is injected into a system at a given frequency, a linear
system will respond at that same frequency with a certain magnitude and a certain phase angle
relative to the input. Also for a linear system, doubling the amplitude of the input will double the
amplitude of the output.

MATLAB CODE:
( s − 1) s −1
% for example H ( s ) = = 2
( s + 4) 2
s + 8s + 8
clc;
clear all;
close all;
syms t s ;
syms w float;
num=[0 1 -1]; % defining numerator
den=[1 8 8]; % defining denominator
w=-2*pi:pi/50:2*pi; % defining frequency
[H,w]= freqs(num,den,w); % determining frequency response of system

Fmag=abs(H); % to find magnitude


Fphas=angle(H); % to find phase
subplot(2,1,1);
plot(w,Fmag);
xlabel('w ---->');
ylabel('Magnitude --->');
title('Magnitude spectrum');
grid;
subplot(2,1,2);
plot(w,Fphas);
xlabel('w ---->');
ylabel('Phase in radians--->');
title('Phase spectrum');
grid on ;

24
RESULT: The plot of magnitude and phase response of a given system has been done.

OUTPUT:

25
EXPERIMENT NO - 10
OBJECTIVE: Checking Linearity/Non-Linearity of a system using SIMULINK
a. Build a system that amplifies a sine wave by a factor of two.
b. Test the linearity of this system using SIMULINK.

TOOL REQUIREMENT: MATLAB

THEORY:

Linearity: Suppose that when one inputs is x1 to a system, the output of the system is y1, and
when other input is x2 to a system, the output of the system is y2. A system is said to be linear if
the input to the system is α1x1+ α 2x2, then the output of the system will be α1y1 + α2y2. Linear
systems are said to satisfy the principle of superposition.

Simulink: To see when a system is linear and when it is not, we make use of Simulink a
MATLAB “add-on." Simulink is, essentially, a graphical user interface (GUI) to MATLAB. It
allows to drag-and-drop blocks to build up a system.

SIMULINK OPERATION:
1. To open Simulink, type “simulink" at the MATLAB command prompt. Alternatively click on
the Simulink icon on the toolbar in the main MATLAB window.
2. After performing either of these actions, the Simulink Library Browser will open. After it has
opened, click on the blank page in this window's toolbar to open a new Simulink page.
3. To start working, drag and drop items from the library browser into the worksheet, connects
the items and run the simulation.

(a) Amplification of a sine wave by a factor of two:


1. Go to the browser, click on the sources" tab (in the Simulink blockset) and then drag a “sine
wave" over to the untitled worksheet, save the worksheet. Simulink saves its worksheets with a
.mdl extension.
2. Go to the “Math Operations" tab, click on it and drag a gain block to the worksheet. To
connect the sine wave to the gain block select the sine wave block, hold down the control key
and left-click on the gain block.
3. Go to the “Sinks" tab, click on it, and drag a Scope block from the right- hand panel to the
worksheet. Then connect the gain block to the scope.
4. Double click on the gain block, and use the dialog box that opens to change the gain of the
gain block from 1 to 2. Double click on the sine wave block, and change its frequency from 1
radian per second to 2 radians per second. (Enter 2 * pi as the frequency.)
5. Double click on the scope to actually open a scope window. Finally hit the “play" button on
top of the worksheet window, and a sine wave should appear in the scope window.

26
6. In order to improve the quality of the sine wave, click on the sine wave block again and
change the sample time from zero to 0.001s.

b. Testing the linearity of the system using SIMULINK:


Build the following system-

1. To copy a block, hold down the control key, left-click on the block and drag the copy to
wherever it is needed.
2. The summing block (the circle with the pluses inside) is located in the “Math Operations"
library.
3. Double clicking on the summing block opens up a dialog box that allows change from sums to
differences.
4. In order to open a scope window, double click on the scope of interest. If one does not see the
whole signal on a scope, go to the scope window. Go to the “parameters" tab (the second tab
from the left) and click on it. A dialog box will open. Click on the “data history" tab, and unclick
the “limit data points to last" box.

RESULT: Building and Testing of linear system is done using SIMULINK.

OUTPUT:

27
EXPERIMENT NO - 11
OBJECTIVE: Verification of sampling theorem using MATLAB..

TOOL REQUIREMENT: MATLAB

THEORY: The sampling theorem specifies the minimum-sampling rate at which a continuous-
time signal needs to be uniformly sampled so that the original signal can be completely
recovered or reconstructed by these samples alone. This is usually referred to as Shannon's
sampling theorem in the literature.

A band-limited signal can be reconstructed exactly if it is sampled at a rate at least twice the
maximum frequency component in it.

Aliasing:

In reconstructing a signal from its samples, there is another practical difficulty. The sampling
theorem was proved on the assumption that the signal x(t) is bandlimited. All practical signals
are time limited, i.e., they are of finite duration. As a signal cannot be time limited and
bandlimited simultaneously

MATLAB CODE:
t=-10:.01:10;
T=4;
fm=1/T;
x=cos(2*pi*fm*t);
subplot(2,2,1);
plot(t,x);
xlabel('Time');
ylabel('x(t)')
title('Continous time signal')
grid;
n1=-4:1:4
fs1=1.6*fm;
fs2=2*fm;
fs3=8*fm;
x1=cos(2*pi*fm/fs1*n1);
subplot(2,2,2);
stem(n1,x1);
xlabel('Time');
ylabel('x(n)')
title('Discrete time signal with fs<2fm')
hold on
subplot(2,2,2);
plot(n1,x1)

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

RESULT: In this experiment the sampling theorem have been verified using MATLAB.

29
OUTPUT:

30
EXPERIMENT NO - 12
OBJECTIVE: Implementation of decimation and interpolation processes using MATLAB

TOOL REQUIREMENT: MATLAB

THEORY:

Interpolation is the process of increasing the sampling frequency of a signal to a higher sampling
frequency that differs from the original frequency by an integer value. Interpolation also is
known as up-sampling. The spectrum of the output signal ideally is the same as the input signal
spectrum, except the output signal spectrum contains an additional high-frequency region with
zero-power density.

Down sampling, compression, and decimation are terms associated with the process of
resampling in a multi-rate digital signal processing system. Both down sampling and decimation
can be synonymous with compression, or they can describe an entire process of bandwidth
reduction (filtering) and sample-rate reduction. When the process is performed on a sequence of
samples of a signal or a continuous function, it produces an approximation of the sequence that
would have been obtained by sampling the signal at a lower rate (or density, as in the case of a
photograph).

MATLAB CODE:

clear all;
close all;
fs=1000; %Sampling frequency
a=1.5; %relative amplitudes
b=1;
f1=100; %Values of f1 and f2
f2=200;
t=0:1/fs:1; %time vector
x=a*cos(2*pi*f1*t)+b*cos(2*pi*f2*t); %generation of x(t);
y=interp(x,3); %interpolate signal by 3
subplot(3,1,1)
stem(x(1:25)); %plot original signal
xlabel('Discrete time,nT')
ylabel('Amplitude');
title('Input signal')
subplot(3,1,2)

31
stem(y(1:100)); %plot interpolated signal
xlabel('Discrete time,3*nT')
ylabel('Amplitude');
title('Interplolated output signal')
y1=decimate(t,3);
subplot(3,1,3)
stem(y1(1:25)); %plot decimated signal
xlabel('Discrete time,nT')
ylabel('Amplitude');
title('Decimated output signal')

RESULT: Decimation and interpolation processes using MATLAB has been performed.

OUTPUT:

32

You might also like