0% found this document useful (0 votes)
6 views56 pages

Digtal Simulation Lab Student Manual-2022 Reg

The document is a laboratory manual for a Digital Simulation Lab course, detailing various experiments related to signals and systems, control systems, and their implementations using MATLAB. Each experiment includes objectives, required software and hardware, theoretical background, procedures, and sample MATLAB code for generating different signals and performing convolution operations. The manual is structured to guide students through practical applications of digital signal processing concepts.

Uploaded by

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

Digtal Simulation Lab Student Manual-2022 Reg

The document is a laboratory manual for a Digital Simulation Lab course, detailing various experiments related to signals and systems, control systems, and their implementations using MATLAB. Each experiment includes objectives, required software and hardware, theoretical background, procedures, and sample MATLAB code for generating different signals and performing convolution operations. The manual is structured to guide students through practical applications of digital signal processing concepts.

Uploaded by

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

FORM NO.

F/TL/018

SUBJECT CODE-EBEC22L04

SUBJECT NAME-DIGITAL SIMULATION LAB

LAB MANUAL-STAFF MANUAL

1
FORM NO.F/TL/018

LABORATORY MANUAL

Faculty
ENGINEERING AND TECHNOLOGY

Course , Department & B.TECH,ECE


Specialization ( If applicable)
Year / Sem. / Sec.
II/IV

Sub code
EBEC22L04

Sub Name
DIGITAL SIMULATION LAB

LIST OF EXPERIMENTS
Name of the Experiment Linked Page
NO.
PO / PSO No.
SIGNALS AND SYSTEMS
Generation of Signal Sequence PO1,PO3,PO4,PO5/ 5
1 PS01,PSO2,PSO4

2
Sampling & Waveform Generation PO1,PO3,PO4,PO5/
PS01,PSO2,PSO4
9

3
Representation of Time-Series; Computation Of Convolution PO1,PO3,PO4,PO5/
PS01,PSO2,PSO4
17

PO1,PO3,PO4,PO5/ 24
Stability of LTI System. PS01,PSO2,PSO4
4

PO1,PO3,PO4,PO5/ 27
Dft & Idft Computation PS01,PSO2,PSO4
5

CONTROL SYSTEM

6
Impulse Response of First and Second Order Systems PO1,PO3,PO4,PO5/
PS01,PSO2,PSO4
33

7
Time Domain Specifications for Closed Loop Transfer Function PO1,PO3,PO4,PO5/
PS01,PSO2,PSO4
36

PO1,PO3,PO4,PO5/ 40
Bode Plot and Polar Plot For Open Loop System PS01,PSO2,PSO4
8

PO1,PO3,PO4,PO5/ 44
Stability Check Using Routh-Hurwitz Criterion bode Plot and Root PS01,PSO2,PSO4

9 Locus.

2
FORM NO.F/TL/018

Determination of Controllability, Observability and Transfer PO1,PO3,PO4,PO5/ 49


10 PS01,PSO2,PSO4
Function from State Model

Prepared by Reviewed by Approved by

3
FORM NO.F/TL/018

SIGNALS AND SYSTEMS

4
FORM NO.F/TL/018

Expt. No.01
Date

GENERATION OF DIFFERENT SIGNALS

AIM:

To write a program in MATLAB to generate different test signals

SOFTWARE REQUIRED:
 MATLAB SOFTWARE

HARDWARE REQUIRED:
 PERSONAL COMPUTER

THEORY:
Unit Step Function
Unit step function is denoted by u(t). It is defined as u(t) = {10t⩾0t<0{1t⩾00t<0

 It is used as best test signal.


 Area under unit step function is unity
Exponential Signal
Exponential signal is in the form of x(t) = eαteαt.
The shape of exponential can be defined by αα.
Case i: if αα = 0 →→ x(t) = e0e0 = 1

5
FORM NO.F/TL/018

Case ii: if αα < 0 i.e. -ve then x(t) = e−αte−αt. The shape is called decaying exponential.

Case iii: if αα > 0 i.e. +ve then x(t) = eαteαt. The shape is called raising exponential.

Unit Impulse Function


Impulse function is denoted by δ(t). and it is defined as δ(t) = {10t=0t≠0{1t=00t≠0

∫∞−∞δ(t)dt=u(t)∫−∞∞δ(t)dt=u(t)
δ(t)=du(t)dtδ(t)=du(t)dt

Ramp Signal

Ramp signal is denoted by r(t), and it is defined as r(t) = {t0t⩾0t<0{tt⩾00t<0

∫u(t)=∫1=t=r(t)∫u(t)=∫1=t=r(t)
u(t)=dr(t)dtu(t)=dr(t)dt

Area under unit ramp is unity.

6
FORM NO.F/TL/018

PROCEDURE:
 Open the Matlab file
 Type the program in the editor window
 Save the file with .m extention and run the program
 Verify output in command window

PROGRAM:

clc
close
all clear
all
t=-2:1:2;
y=[zeros(1,2), ones(1,1),
zeros(1,2)]; subplot(2,2,1);
stem(t,y);
ylabel('d(n)');
xlabel('unit impulse');
n=input('Enter n values');
t=0:1:n-1;
y1=ones(1,n);
subplot(2,2,2);
stem(t,y1);
ylabel('Amplitude');
xlabel('unit step');
n=input('Enter n values');
t=0:1:n-1;
subplot(2,2,3);
stem(t,t);
ylabel('Amplitude');
xlabel('unit ramp');
n=input('Enter length of exponential
seq'); t=0:1:n-1;
a=input('Enter a value');
y2=exp(a*t);
subplot(2,2,4);
stem(t,y2);
xlabel('Exponential fun');
ylabel('Amplitude');

7
FORM NO.F/TL/018

OUTPUT:

RESULT:
Thus the different test signals are generated with MATLAB

8
FORM NO.F/TL/018

VIVA QUESTIONS:

1. What is the purpose of using a unit step function as a test signal?

The unit step function (u(t)) is used to simulate the sudden change or onset of a signal. It is valuable in
testing system responses to abrupt changes in input.

2. How is an exponential signal characterized in terms of its parameter α?

An exponential signal x(t) = e^(αt) exhibits different behaviors based on α: α = 0 yields a constant
signal, α < 0 results in a decaying signal, and α > 0 produces a growing signal.

3. Define the unit impulse function (δ(t)) and its integral properties.

δ(t) is defined such that δ(t) = 1 when t = 0 and 0 otherwise. Its integral from minus infinity to infinity
gives the unit step function u(t), and its derivative is the unit step function, u(t).

4. What is the significance of the ramp signal (r(t))?

The ramp signal r(t) = t for t ≥ 0 and 0 for t < 0 is used to test systems where outputs are expected to
increase linearly over time, such as in systems involving velocity or displacement.

5. How can you generate these test signals in MATLAB?

By defining the necessary time vectors and signal equations in MATLAB, such as using 'stem' for
discrete signals and 'plot' for continuous signals, these test signals can be graphically represented and
analyzed.

8
FORM NO.F/TL/018

Expt. No.02

Date

SAMPLING AND WAVEFORM GENERATION

AIM:

To write a program in MATLAB for sampling and waveform generation

SOFTWARE REQUIRED:
 MATLAB SOFTWARE

HARDWARE REQUIRED:
 PERSONAL COMPUTER

THEORY:
Triangular Signal
Let it be denoted as x(t)

Sinusoidal Signal
Sinusoidal signal is in the form of x(t) = A cos(w0±ϕw0±ϕ) or A sin(w0±ϕw0±ϕ)
9
FORM NO.F/TL/018

Where T0 = 2πw0

Square Signal
Let it be denoted as x(t) and it is defined as

PROCEDURE:
 Open the Matlab file
 Type the program in the editor window
 Save the file with .m extention and run the program
 Verify output in command window

PROGRAM:

Plot an sinusoidal sequence


clc;
clear all;
close all;

N = 50; % Length of the sequence


n = 0:1:N-1; % Discrete time index

% Cosine sequence
xn_cos = cos(0.2 * pi * n);

subplot(2, 2, 1);
stem(n, xn_cos);
10
FORM NO.F/TL/018

xlabel('n');
ylabel('x[n]');
title('Cosine Sequence - stem');

subplot(2, 2, 2);
plot(n, xn_cos);
xlabel('n');
ylabel('x[n]');
title('Cosine Sequence - plot');

% Sine sequence
xn_sin = sin(0.2 * pi * n);

subplot(2, 2, 3);
stem(n, xn_sin);
xlabel('n');
ylabel('x[n]');
title('Sine Sequence - stem');

subplot(2, 2, 4);
plot(n, xn_sin);
xlabel('n');
ylabel('x[n]');
title('Sine Sequence - plot');

triangular wave generation


y=0:0.5:2;
for j=0:3
x=(4*j)+y;
plot(x,y)
hold on
end
for k=0:3
x=(4*k)-y;
plot(x,y)
hold on
end
hold off

sawtooth wave generation


y=0:.5:2 ;
for j=0:8 a=(2*j)
+y; plot(a,y,'b')
hold on end
x=2:2:18;
11
FORM NO.F/TL/018

for k=0:.01:2 b=k; plot(x,b,'b') hold on


end
hold off

generation of square wave

y=0:.001:2; for j=0:2:12 x=y;


plot(j * ones(size(y)), x,'r');
hold on;
end
for k=0:4:12 x=k+y;
m=2;
plot(x,m *ones(size(x)),'r')
hold on;
end
for k=2:4:12 x=k+y;
m=0;
plot(x,m * ones(size(x)), 'r');
hold on;
end
hold off;
axis([0 12 -0.5 2.5])

12
FORM NO.F/TL/018

OUTPUT:

SINUSOIDAL SEQUENCE

TRIANGULAR SEQUENCE

13
FORM NO.F/TL/018

SAWTOOTH WAVE GENERATION

SQUARE WAVE SEQUENCE

14
FORM NO.F/TL/018

RESULT:

Thus the different waveforms are generated with MATLAB

15
FORM NO.F/TL/018

VIVA QUESTIONS:

1. Explain the difference between a sinusoidal sequence and a triangular wave.

A sinusoidal sequence varies sinusoidally with time, while a triangular wave consists of linear ramps in both
upward and downward directions, forming a triangular shape.

2. How can you generate a triangular waveform using MATLAB?

Triangular waveforms in MATLAB are generated by using loops and plotting commands to create
successive linear ramps that form the characteristic triangular shape.

3. Describe the procedure to plot a sinusoidal sequence in MATLAB.

To plot a sinusoidal sequence in MATLAB, define the sequence parameters (such as number of samples and
frequency), compute sequence values using sine or cosine functions, and use plotting functions like 'stem' or
'plot' for visualization.

4. What is the advantage of using a sawtooth wave over other waveforms in certain applications?

Sawtooth waves are advantageous for applications requiring linear sweep signals due to their linear rise and
abrupt fall, which are useful in signal processing, audio synthesis, and circuit testing.

5. Explain the significance of specifying axis limits in a waveform plot.

Specifying axis limits ensures the waveform plot is displayed with appropriate scaling and range, improving
clarity and facilitating the analysis of waveform characteristics such as amplitude and periodicity.

16
FORM NO.F/TL/018

Expt. No.03
Date

REPRESENTATION OF TIME –SERIES COMPUTATION OF


CONVOLUTION

AIM:

To write a program in MATLAB for sampling and waveform generation

SOFTWARE REQUIRED:
 MATLAB SOFTWARE

HARDWARE REQUIRED:
 PERSONAL COMPUTER

THEORY
 Linear convolution is the basic operation to calculate the output for any linear time invariant
system given its input and its impulse response.
 Circular convolution is the same thing but considering that the support of the signal is periodic
(as in a circle, hence the name).
 Most often it is considered because it is a mathematical consequence of the discrete Fourier
transform (or discrete Fourier series to be precise):
 One of the most efficient ways to implement convolution is by doing multiplication in the
frequency.

PROCEDURE:
 Open the Matlab file
 Type the program in the editor window
 Save the file with .m extention and run the program
 Verify output in command window

PROGRAM:
Linear Convolution program

x=[1 4 2 4 1 1]; h=[1 2 3 4 5];


len1=length(x);
len2=length(h);
17
FORM NO.F/TL/018

len=len1+len2-1;
a=fliplr(h);
for i=1:len c(i)=0;
for j=1:len1
if j>i
continue; end
if(len2-i+j)<=0 continue;
end
c(i)=c(i)+(x(j)*a(len2-i+j));
end
end
k=1:len;
conv_op1=c(1:len)
subplot(2,1,1),stem(k,conv_op1);
title('linear convolution method')

OUTPUT:

18
FORM NO.F/TL/018

Circular Convolution program


clc
clear all
close all
%circular convolution of the two sequences
hc = [1,1,1,1,2,2,2,2];
xc = [1,2,3,3,1,1,1,1];
disp('Result of Circular Convolution:');
%Outputting Text to Command Console
%Determine Lengths of Inputs
N1 = length(hc);
N2 = length(xc);
%Step 1: If Inputs are of Different Lengths, Zero Pad the Shorter input
if(N1 ~= N2)
if(N2 >
N1) N =
N2;
tmp = hc;
hc = zeros(1,N);
for k = 1:N1
hc(1,k) = tmp(1,k);
end
else
N = N1;
tmp = xc;
xc = zeros(1,N);
for k = 1:N2
xc(1,k) = tmp(1,k);
end
end
else
N = N1;
end
Output = zeros(1,N);
%Initialize Output to Contain N Samples
Input2r = zeros(1,N);
%Initialize Circular Time Reversal Array

%Step 2: Find Circular, Time Reversed Input:


for k = 1:N
if(k == 1)

19
FORM NO.F/TL/018

%Keep First Sample Same for Time-Reversed Sequence

20
FORM NO.F/TL/018

Input2r(1,k) = xc(1,1);
else
Input2r(1,k) = xc(1,N-k+2);
end
end
Input2rs = zeros(1,N);
%Initialize Circular Shift Array to N Samples

%Step 3: Calculate The Output


for n = 0:N-1
for k = 1:N
k1 = 0;

%Peform Circular Shift:


if(k+n <= N)
Input2rs(1,n+k) = Input2r(1,k);
k1 = k+n;
else
Input2rs(1,n+k-N) = Input2r(1,k);
k1 = n+k-N;
end
Output(1,n+1) = hc(1,k1)*Input2rs(1,k1) + Output(1,n+1);
end
end
y=Output
m=1:N;
subplot(2,1,1),stem(m,y);
title('circular convolution method')

21
FORM NO.F/TL/018

OUTPUT:

22
FORM NO.F/TL/018

RESULT:

Thus the linear convolution and circular of two discrete signals are performed and analysed
using
MATLAB.

23
FORM NO.F/TL/018
VIVA QUESTIONS:

1. Explain the difference between linear convolution and circular convolution.

Linear convolution computes the output of a linear time-invariant system by convolving the input with
the impulse response directly. Circular convolution, on the other hand, assumes periodicity in the input
signals, wrapping around the end to the beginning, and is often computed using the Discrete Fourier
Transform (DFT) due to its periodic nature.

2. What is the significance of zero-padding in circular convolution?

Zero-padding ensures that both sequences involved in circular convolution are of the same length,
aligning them properly for computation. It prevents aliasing and ensures accurate circular shifting
during the convolution process.

3. Describe the computational advantage of using the frequency domain for convolution.

In the frequency domain, convolution can be computed efficiently using multiplication, leveraging the
properties of the Fourier transform. This approach reduces the computational complexity from O(N^2)
in time domain convolution to O(N log N) when using FFT-based methods, where N is the length of the
signals.

4. Why is circular convolution useful in certain signal processing applications?

Circular convolution is useful when dealing with signals that exhibit periodic behavior or when
implementing circular shift operations. It finds applications in digital filtering, cyclic signal processing,
and in efficiently simulating periodic systems.

5. Explain the procedure for implementing linear convolution in MATLAB.

In MATLAB, linear convolution is implemented by zero-padding the input signals to avoid aliasing,
reversing one of the signals (typically the impulse response), and sliding it across the other signal while
accumulating the product at each shift position.

6. How does MATLAB handle the output of convolution operations?

MATLAB computes the linear convolution using the 'conv' function or manually as shown in the
program. For circular convolution, MATLAB often employs techniques involving circular shifting and
multiplication, sometimes utilizing FFT for efficiency in handling large datasets

24
FORM NO.F/TL/018

Expt. No.04
Date
STABLITY OF LTI SYSTEMS

AIM:

To write a program in MATLAB to check the stability of LTI the systems.

SOFTWARE REQUIRED:
 MATLAB SOFTWARE

HARDWARE REQUIRED:
 PERSONAL COMPUTER
THEORY:
 If a system in equilibrium is disturbed and the system returns back to the equilibrium point
with time, then the equilibrium point is said to be stable
 In signal processing, specifically control theory, bounded-input, bounded-output (BIBO)
stability is a form of stability for linear signals and systems that take inputs. If a system is
BIBO stable, then the output will be bounded for every input to the system that is
bounded.
 LTI system is stable if its impulse response is absolutely summable ie ,finite
∑k=−=h(k)|<∞ where varies from -∞ to +∞
PROCEDURE:
 Open the Matlab file
 Type the program in the editor window
 Save the file with .m extention and run the program
 Verify output in command window

PROGRAMS:
To check stability of a system
num=[1 0.8];
den=[1 1.5 .9];
N=200;
h=impz(num,den,N+1);
sum=0;
n=0:N;
for k=1:N+1

25
FORM NO.F/TL/018

if abs(h(k))<10^(-6);
break
end
sum=sum+h(k);
end
stem(n,h);
grid;
disp('Value='), disp(sum)

OUTPUT:

RESULT:

Thus the stability of the LTI system studied and Analyzed.

26
FORM NO.F/TL/018

VIVA QUESTIONS:

1. Explain what it means for an LTI system to be stable.

An LTI (Linear Time-Invariant) system is stable if its impulse response is absolutely summable, meaning
the sum of the absolute values of its impulse response coefficients is finite.

2. What is the significance of bounded-input, bounded-output (BIBO) stability in signal processing?

BIBO stability ensures that if the input to a system is bounded, the output will also be bounded. This
property is crucial in ensuring predictable and controlled behavior of systems in response to various inputs.

3. Describe the procedure implemented in the MATLAB program to check system stability.

The MATLAB program calculates the impulse response of the system using impz, then sums up the
absolute values of the impulse response coefficients until a very small value is encountered (indicating the
response is negligible), which signifies stability. The sum is then displayed to verify stability.

4. What is the role of the impz function in the stability check program?

The impz function in MATLAB calculates the impulse response of a system defined by its numerator ( num)
and denominator (den) coefficients. It provides the sequence of output values in response to an impulse
input, crucial for stability analysis based on the sum of these responses.

5. How does MATLAB handle the determination of stability based on the impulse response?

MATLAB evaluates the stability by examining the impulse response sequence ( h), summing its absolute
values until they become negligibly small. If the sum converges and remains finite, the system is deemed
stable.

6. What would be the output of the stability check program for an unstable system?

For an unstable system, the sum of the impulse response coefficients would not converge to a finite value
but instead would diverge or oscillate indefinitely, indicating instability

27
FORM NO.F/TL/018

Expt. No.05
Date
DFT AND IDFT COMPUTATION

AIM:

To write a program in MATLAB for designing a DFT and IDFT of any two N values Of
sequences and plot the magnitude and phase.

SOFTWARE REQUIRED:
 MATLAB SOFTWARE

HARDWARE REQUIRED:
 PERSONAL COMPUTER
THEORY:
 The discrete Fourier transform (DFT) converts a finite sequence of equally-
spaced samples of a function into a same-length sequence of equally-spaced samples of
the discrete-time Fourier transform (DTFT), which is a complex-valued function of
frequency. The interval at which the DTFT is sampled is the reciprocal of the duration of the
input sequence.
 An inverse DFT(IDFT) is a Fourier series, using the DTFT samples as coefficients
of complex sinusoids at the corresponding DTFT frequencies. It has the same sample-values
as the original input sequence.
 The DFT is therefore said to be a frequency domain representation of the original input
sequence.
 The DFT is also used to efficiently solve partial differential equations, and to perform other
operations such as convolutions or multiplying large integers.

PROCEDURE:
 Open the Matlab file
 Type the program in the editor window
 Save the file with .m extention and run the program
 Verify output in command window

28
FORM NO.F/TL/018

PROGRAM: DFT
Main Program:
clear all;

x=ones(1,4);
%input sequence
N1=8;
%No.of frequency points Y1=dft(x,N1);
k=0:1:N1-1;
subplot(2,2,1),stem(k,abs(Y1));
xlabel('K'),ylabel('|Y1(k)|');
subplot(2,2,3),stem(k,angle(Y1));
xlabel('K'),ylabel('arg(Y1(k))'); N2=31;
Y2=dft(x,N2);
k=0:1:N2-1;
subplot(2,2,2),stem(k,abs(Y2));
xlabel('K'),ylabel('|Y2(k)|');
subplot(2,2,4),stem(k,angle(Y2));
xlabel('k'),ylabel('arg(Y2(k))');

Actual Program:

function X=dft(xn,N)
L=length(xn);
if(N<L);
error('N must be >=L')
end
x1=[xn zeros(1,N-L)]; for
k=0:1:N-1;
for n=0:1:N-1;
p=exp(-i*2*pi*n*k/N);
x2(k+1,n+1)=p;
end
end
X=x1*x2.';

29
FORM NO.F/TL/018

OUTPUT:

30
FORM NO.F/TL/018

PROGRAM: IDFT

Main Program:
clear all;
X=[4,1+i,0,1-i,0,1+i,0,1-i];
N=length(X);
xn=idft(X,N)

Actual Program:
function xn=idft(X,N)
N=length(X);
for k=0:1:N-1;
for n=0:1:N-1;
p=exp(i*2*pi*n*k/N);
x2(k+1,n+1)=p;
end
end
xn=(X*x2.')/N;

OUTPUT:

RESULT:

Thus the DFT and IDFT of the two N valued sequences are determined and verified using

MATLAB.

31
FORM NO.F/TL/018

VIVA QUESTIONS:

1. Explain the purpose of the Discrete Fourier Transform (DFT) in signal processing.

DFT converts a finite sequence into its frequency domain representation, crucial for analyzing signal
frequencies and performing spectral operations.

2. What does the magnitude plot represent in the DFT output?

The magnitude plot shows the amplitude of each frequency component extracted by the DFT, indicating
their contributions to the signal.

3. Why is it important to zero-pad the input sequence in the DFT implementation?

Zero-padding ensures accurate frequency resolution and prevents aliasing, especially when analyzing
signals with specific spectral features.

4. Explain the relationship between the DFT and Inverse DFT (IDFT).

DFT transforms signals into the frequency domain, while IDFT reconstructs the original signal from its
frequency components, forming a Fourier pair.

5. What would be the output of the IDFT program for a given sequence of complex numbers?

The IDFT program computes the time-domain sequence corresponding to the input complex numbers, often
resulting in a real-valued output representing the original signal.

32
FORM NO.F/TL/018

CONTROL SYSTEM

33
FORM NO.F/TL/018

Expt. No.06

Date

IMPULSE RESPONSE OF FIRST AND SECOND ORDER


SYSTEMS
AIM:

To write a program in MATLAB for Impulse Response Of First And Second Order Systems

SOFTWARE REQUIRED:
 MATLAB SOFTWARE

HARDWARE REQUIRED:
 PERSONAL COMPUTER
THEORY:
 The system whose input-output equation is a first order differential equation is
called first order system. The order of the differential equation is the highest degree of derivative
present in an equation. First order system contains only one energy storing element
 A system whose input-output equation is a second order differential equation is
called Second Order System. There are a number of factors that make second order systems
important. They are simple and exhibit oscillations and overshoot. Higher order systems are
based on second order systems
 An impulse response means the output/ behavior of a system/process when we provide
it with an impulse signal. The Laplace transform of an impulse function is 1, so the impulse
response is equivalent to the inverse Laplace transform of the system's transfer function, for an
LTI system.

PROCEDURE:
 Open the Matlab file
 Type the program in the editor window
 Save the file with .m extention and run the program
 Verify output in command window

34
FORM NO.F/TL/018

PROGRAM:
clc;
close all;
clear all;
M1 = tf([1, 0],[1, 1]);
M2 = tf([0, 1, 0],[1, 1, 1]);
disp('Impulse response of the system is:');
subplot(2,1,1);
impulse(M1);
grid on;
title('Impulse response of M1 = s / (s + 1)');
xlabel('Time');
ylabel('Amplitude');
subplot(2,1,2);
impulse(M2);
grid on;
title('Impulse response of M2 = s / (s^2 +s+1)');
xlabel('Time');
ylabel('Amplitude');

OUTPUT:

35
FORM NO.F/TL/018

RESULT:

Thus the Impulse Response of First and Second Order Systems studied and Analysed

VIVA QUESTIONS:

1. Define a first order system and its characteristic differential equation.

A first order system has one energy storing element and is described by a differential equation with the highest
derivative being of the first degree.

2. What distinguishes a second order system from higher-order systems?

A second order system is characterized by a second order differential equation, exhibiting oscillatory behavior
and overshoot, which are fundamental in understanding more complex systems.

3. Explain what an impulse response signifies in the context of system analysis.

The impulse response of a system depicts its output when subjected to an impulse input, providing insights into
the system's dynamics and characteristics.

4. How does MATLAB compute the impulse response of systems defined by transfer functions?

MATLAB uses the ilaplace function to compute the inverse Laplace transform of the transfer function,
yielding the time-domain impulse response which is then plotted using impulse.

5. What are the practical implications of plotting and analyzing impulse responses in system engineering?

Impulse responses help engineers assess system stability, frequency response, and transient behavior, aiding in
design and optimization processes.

36
FORM NO.F/TL/018

Expt. No.07
Date

TIME DOMAIN SPECIFICATION FOR CLOSED LOOP TRANSFER


FUNCTION
AIM:

To write a program in MATLAB to Time Domain Specification for Closed Loop Transfer
Function.

SOFTWARE REQUIRED:
MATLAB SOFTWARE

HARDWARE REQUIRED:
PERSONAL COMPUTER

THEORY:
Delay time td: It is the time required for the response to reach 50% of the steady state value for the
first time
Rise time tr: It is the time required for the response to reach 100% of the steady state value for under
damped systems. However, for over damped systems, it is taken as the time required for the response
to rise from 10% to 90% of the steady state value. Generally the formula of equating Rise time
Peak time tp: It is the time required for the response to reach the maximum or Peak value of the
response.
Settling time ts : It is the time required for the response to reach and remain within a specified
tolerance limits (usually ± 2% or ± 5%) around the steady state value.

PROCEDURE:

 Open the Matlab file


 Type the program in the editor window
 Save the file with .m extention and run the program
 Verify output in command window

37
FORM NO.F/TL/018

PROGRAM:
clc;
clear all;
close all;
t = 0:0.005:5;
num_cof = [0 0 16];
den_cof = [1 4 16];
[c, x, t] = step(num_cof, den_cof, t);
n = 1;
while c(n) < 1.0001 && n < length(c)
n = n + 1;
end
rise_time = (n - 1) * 0.005;
disp('Rise time of system is =');
disp(rise_time);
[cmax, tp] = max(c);
peak_time = (tp - 1) * 0.005;
disp('Peak time of system is =');
disp(peak_time);
max_overshoot = cmax - 1;
disp('Maximum overshoot of system is =');
disp(max_overshoot);
n = length(c);
while (c(n) > 0.95 && c(n) < 1.05) && n > 1
n = n - 1;
end
settling_time_5per_err = (n - 1) * 0.005;
disp('Settling time of system (5% error band) is =');
disp(settling_time_5per_err);
n = length(c);
while (c(n) > 0.98 && c(n) < 1.02) && n > 1
n = n - 1;
end
settling_time_2per_err = (n - 1) * 0.005;
disp('Settling time of system (2% error band) is =');
disp(settling_time_2per_err);
figure;
plot(t, c, 'b', 'LineWidth', 1.5);
grid on;
title('Step Response of the System');
xlabel('Time (s)');
ylabel('Response');

38
FORM NO.F/TL/018
OUTPUT:

RESULT:

Thus the Time Domain Specification for Closed Loop Transfer Function is analysed andstudied

39
FORM NO.F/TL/018

VIVA QUESTIONS:

1. Define delay time (td) in the context of system response analysis.

Delay time (td) is the time required for the system response to reach 50% of its steady state value for the
first time after an input is applied.

2. How does MATLAB compute the rise time (tr) of a system's response?

MATLAB calculates rise time (tr) as the time taken for the response to rise from 0% to 100% of its steady
state value for underdamped systems, or from 10% to 90% for overdamped systems.

3. Explain what peak time (tp) signifies in system dynamics.

Peak time (tp) is the time taken for the system response to reach its maximum value during transient
oscillations before settling to its steady state.

4. What is settling time (ts) and how is it determined using MATLAB?

Settling time (ts) is the duration within which the system response stays within a specified tolerance band
around its steady state. MATLAB computes it based on predefined percentage error criteria.

5. Why is it important to determine maximum overshoot in system analysis?

Maximum overshoot indicates the maximum deviation of the system response from its steady state value. It
is crucial for assessing stability and ensuring that the system does not exhibit excessive oscillations or
instability.

40
FORM NO.F/TL/018

Expt. No.08
Date
BODE PLOT AND POLAR PLOT FOR OPEN LOOP SYSTEM

AIM:

To write a program in MATLAB to draw the bode plot and polar plot for the open Loop system

SOFTWARE REQUIRED:
 MATLAB SOFTWARE

HARDWARE REQUIRED:
 PERSONAL COMPUTER

THEORY

 A Bode Plot is a useful tool that shows the gain and phase response of a given LTI system for
different frequencies. Bode Plots are generally used with the Fourier Transform of a given
system.

 Polar plot is a plot of magnitude versus phase angle in complex plane. (i.e. locus of magnitude
traced by the phase or by varying frequency from to i n f i n i t y .) Advantage - it can be capture
thesystem behavior over the entire frequency range in a single plot

PROCEDURE:
 Open the Matlab file
 Type the program in the editor window
 Save the file with .m extention and run the program
 Verify output in command window

41
FORM NO.F/TL/018
PROGRAM:

clc;
close all;
clear all;
n = [0, 0, 1];
d = [1, 1, 1];
sys = tf(n, d);
figure;
subplot(2,1,1);
bode(sys);
grid on;
title('Bode Plot of M1');
w = 0.4:0.01:4;
[re, im] = nyquist(sys, w);
re = squeeze(re);
im = squeeze(im);
r = abs(re + 1i*im);
theta = angle(re + 1i*im);
subplot(2,1,2);
polarplot(theta, r, 'k');
title('Polar Plot of M');
grid on;

OUTPUT:

42
FORM NO.F/TL/018

RESULT:

Thus the bode plot and polar plot for the open Loop system is plotted for the given transfer function

43
FORM NO.F/TL/018

VIVA QUESTIONS:

1. Explain the purpose of a Bode Plot in system analysis.

A Bode Plot illustrates the frequency response of a system, showing how the gain and phase shift of the
system vary with frequency, crucial for understanding stability and performance.

2. What information does the magnitude plot provide in a Bode Plot?

The magnitude plot in a Bode Plot displays the ratio of output amplitude to input amplitude (gain) across
different frequencies, aiding in frequency domain analysis.

3. Describe the significance of the phase plot in a Bode Plot.

The phase plot in a Bode Plot indicates the phase shift introduced by the system at each frequency,
essential for assessing time delay and phase relationships within the system.

4. What is the advantage of using a polar plot in system characterization?

A polar plot combines magnitude and phase information into a single plot in the complex plane, providing
a holistic view of system behavior across all frequencies.

5. Explain the difference in interpretation between a Bode Plot and a Polar Plot.

A Bode Plot focuses on gain and phase response versus frequency, while a Polar Plot shows how the
magnitude and phase angle vary together in the complex plane, offering a comprehensive view of
system characteristics.

44
FORM NO.F/TL/018

Expt. No.09
Date

STABILITY CHECK USING ROUTH HURWITZ CRITERION PLOT

AND ROOT LOCUS

AIM:

To write a program in MATLAB to check the stability using Routh Hurwitz Criterion and Root Locus

SOFTWARE REQUIRED:
 MATLAB SOFTWARE

HARDWARE REQUIRED:
 PERSONAL COMPUTER
THEORY:
 In control system theory, the Routh–Hurwitz stability criterion is a mathematical test that is a
necessary and sufficient condition for the stability of a linear time invariant (LTI) control system.
The Routh test is an efficient recursive algorithm to determine whether all the roots of the
characteristic polynomial of a linear system have negative real parts
 The coefficients of the polynomial are arranged into a square matrix, called the Hurwitz matrix, and
showed that the polynomial is stable if and only if the sequence of determinants of its principal sub
matrices are all positive.
 The two procedures are equivalent, with the Routh test providing a more efficient way to compute
the Hurwitz determinants than computing them directly. A polynomial satisfying the Routh–
Hurwitz criterion is called a Hurwitz polynomial.
 Root locus analysis is a graphical method for examining how the roots of a system change with
variation of a certain system parameter, commonly again within a feedback system. This is a
technique used as a stability criterion in the field of classical control theory which can
determine stability of the system. The root locus plots the poles of the closed loop transfer
function in the complex s-plane as a function of a gain parameter

PROCEDURE:
 Open the Matlab file
 Type the program in the editor window
 Save the file with .m extention and run the program
 Verify output in command window

45
FORM NO.F/TL/018

PROGRAM:
ROUTH HURWITZ CRITERION
clc;
close all;
clear;

EPS = 0.001; % Small value to avoid division by zero

disp('Routh array for S^3 + 2S^2 + 3S + 1:');


ra = routh([1 2 3 1], EPS);
disp(ra);

disp('Routh array for S^4 + 10S^3 + 2S^2 + 36S + 20:');


ra1 = routh([1 10 2 36 20], EPS);
disp(ra1);

% ---- Routh function ----


function routh_array = routh(coeffs, EPS)
n = length(coeffs);
routh_array = zeros(n, ceil(n/2));

% Fill first two rows


routh_array(1, :) = coeffs(1:2:end);
if length(coeffs) > 1
routh_array(2, 1:length(coeffs(2:2:end))) = coeffs(2:2:end);
end

% Calculate remaining rows


for i = 3:n
for j = 1:ceil(n/2)-1
a = routh_array(i-2,1);
b = routh_array(i-2,j+1);
c = routh_array(i-1,1);
d = routh_array(i-1,j+1);

if c == 0
c = EPS;
end

routh_array(i,j) = ((c*b) - (a*d)) / c;


end

% If row is zero, use auxiliary equation


if all(routh_array(i,:) == 0)
order = n - i + 1;
prev_row = routh_array(i-1,:);
46
aux = zeros(1, length(prev_row));
for k = 1:length(prev_row)-1 FORM NO.F/TL/018
aux(k) = (order - 2*(k-1)) * prev_row(k);
end
routh_array(i,:) = aux;
end
end
end

OUTPUT:

PROGRAM:
ROOT LOCUS
clc
close all
clear all
% Root locus
% M1=0.4K/(s^3+2s^2+4s+5
K=2:2:8;
n=[0.4];
d=[1 2 4 5];
subplot(2,1,1)
rlocus(n,d);
[r,k]=rlocus(n,d,K);
subplot(2,1,2)
plot(r,'o');
grid
title ('root locus plot');
xlabel('real axis');
ylabel('imaginary axis');

47
FORM NO.F/TL/018

OUTPUT

RESULT:

Thus the stability check using Routh Hurwitz Criterion and Root Locus is analysed for the given transfer
function
48
FORM NO.F/TL/018

VIVA QUESTIONS:

1. Explain the purpose of the Routh-Hurwitz criterion in control systems.

The Routh-Hurwitz criterion determines the stability of a system by analyzing the signs of the coefficients
of the characteristic equation's polynomial, ensuring all roots have negative real parts for stability.

2. What does the Routh array signify, and how does MATLAB compute it?

The Routh array organizes coefficients of the characteristic polynomial into a matrix, checking stability via
the signs of its rows and applying recursive determinants. MATLAB's routh function automates this
computation efficiently.

3. Describe the significance of a Hurwitz polynomial in the context of the Routh-Hurwitz criterion.

A polynomial is termed Hurwitz if all determinants of its principal submatrices are positive, indicating
stability as per the Routh-Hurwitz criterion, essential for ensuring a stable control system.

4. What does a root locus plot depict, and how is it useful in control system analysis?

A root locus plot illustrates how the roots (poles) of the closed-loop transfer function change with varying
gain parameters, providing insights into system stability and dynamic response characteristics.

5. What information can you derive from a root locus plot about system stability?

A root locus plot indicates stability by showing whether the poles move into or out of the stable region (left
half of the complex plane) as the gain parameter changes, crucial for designing stable control systems.

49
FORM NO.F/TL/018

Expt. No.10
Date

DETERMINATION OF CONTROLLABLITY AND OBSERVABLITY AND


TRANSFERFUNCTION FROM STATE MODEL
AIM:

To write a program in MATLAB to determine Controllability and Observability and to find Transfer
Function from State Model

SOFTWARE REQUIRED:
 MATLAB SOFTWARE

HARDWARE REQUIRED:
 PERSONAL COMPUTER
THEORY:

 Controllability is concerned with whether one can design control input to steer the state to
arbitrarily values.
 Observability is concerned with whether without knowing the initial state, one can determine
the state of a system given the input and the output.
 A system that is not controllable probably means the followings:
o If state space system is realized from input-output data, then the realization is redundant.
i.e. some states have no relationship to either the input or the output.
o If states are meaningful (physical) variables that need to be controlled, then the design of
the actuators are deficient.
o The effect of control is limited. There is also a possibility of instability

PROCEDURE:
 Open the Matlab file
 Type the program in the editor window
 Save the file with .m extention and run the program
 Verify output in command window

50
FORM NO.F/TL/018

PROGRAM:
CONTROLLABLITY

clc close
all clear
all
%CONTROLLABLITY
disp('the given state model is,');
A=[0 0 1;-2 -3 0; 0 2 -3]
B=[0;2;0]
C=[1 0 0 ]
D=[0]
disp('Controllablity of matrix is,');
Qc=ctrb(A,B)
disp('Number of uncontrollable states is ');
N_ucs=length(A)-rank(Qc)
disp('determinant of Controllablity matrix is');
Det_Qc=det(Qc)
rank_Qc=rank(Qc)
n=size(A);
if (Det_Qc ~= 0 )&(n==rank_Qc);
disp('system is completely stable.');
else
disp('system is completely unstable.');
end;

51
FORM NO.F/TL/018

OUTPUT:

PROGRAM:
OBSERVABLITY
clc close
all clear
all
%OBSERVABLITY
disp('the given state model is,');
A=[0 0 1;-2 -3 0; 0 2 -3]
B=[0;2;0]
C=[1 0 0 ]
D=[0]

52
FORM NO.F/TL/018

disp('Observability of matrix is,');


Qo=obsv(A,C)
disp('Number of unobservable states is ');
N_uos=length(A)-rank(Qo)
disp('determinant of Observability matrix is');
Det_Qo=det(Qo)
rank_Qo=rank(Qo)
n=size(A);
if (Det_Qo ~= 0 )&(n==rank_Qo);
disp('system is completely observable.');
else
disp('system is completely not observable.');
end;

OUTPUT:

PROGRAM:
53
FORM NO.F/TL/018

TO FIND TRANSFER FUNCTION


clc
close all
clear all
disp('the given state model is,');
A=[0 1 0;0 0 1;2 -5 4]
B=[0;0;1]
C=[1 -7 4 ]
D=[4]
syms z
Ts=0.1;
disp('Numerator &Denominator coefficients of transfer function are,');
[num_cof,den_cof]=ss2tf(A,B,C,D)
disp('transfer function of discrete time system is,');
Gz=tf(num_cof,den_cof,Ts)

OUTPUT:

RESULT:
Thus Controllability and Observability check and Transfer Function is analysed for the given State Model
using matlab program

VIVA QUESTIONS:
54
FORM NO.F/TL/018

1. Explain the concept of controllability in the context of state-space systems.

Controllability assesses whether a system's states can be manipulated by choosing appropriate inputs. It
ensures that all states can be driven to desired values using suitable control inputs.

2. What is the significance of the controllability matrix in MATLAB's state-space analysis?

The controllability matrix (Qc) in MATLAB checks if a system is fully controllable. It's computed using ctrb
function, and its rank determines the number of controllable states. A full rank matrix ensures all states can
be controlled.

3. Describe how MATLAB determines the stability of a system based on its controllability matrix.

MATLAB checks system stability by verifying if the determinant of the controllability matrix is non-zero
and matches the system's rank. If so, the system is stable; otherwise, it indicates potential instability due to
uncontrollable states.

4. Define observability and its importance in state-space analysis.

Observability determines whether all states of a system can be estimated from its outputs, regardless of the
initial state. It's crucial for system monitoring and state estimation without direct access to all internal states.

5. How does MATLAB compute the observability matrix, and what does its rank signify?

MATLAB computes the observability matrix (Qo) using the obsv function, assessing how well the system's
internal states can be deduced from its outputs. The rank of Qo indicates the number of observable states in
the system.

6. Explain the process of deriving a transfer function from a state-space model using MATLAB.

MATLAB converts a state-space model to a transfer function using the ss2tf function, which extracts the
numerator and denominator coefficients of the transfer function from the state-space matrices (A, B, C, D).
This facilitates analysis and design in frequency domain tools.

55

You might also like