You are on page 1of 26

SESSION: (2022-23)

PRACTICAL FILE
ON

SUBMITTED TO:- SUBMITTED BY:-


Dr. Aneesh Sir Aviral Chaurasia
Branch: - (E.C.E)
3rd Year, 6th Sem
Roll No- 195209

1
Index

S.No. Object Signature


1. Introduction to MATLAB and Control System Toolbox.
2. Determine transpose inverse values of given matrix.
3. Plot the pole-zero configurations in s-plane for the given
transfer function.
4. Determine the transfer function for closed loop system.
5. Plot the unit step response, impulse response of transfer
function.
6. Plot root locus of given transfer function.
7. Plot bode plot of given transfer function and find phase
and gain margin
8. Plot Nyquist plot of given transfer function.
9. Create the state space model of a linear continuous
system.
10. Determine the state space representation of the transfer
function.
11. Determine the steady state errors of a given transfer
function.
12. Determine the time response of the given system
subjected to any arbitrary input

2
Experiment No. 1

Object: Introduction to MATLAB & to study Control System Toolbox

Software/Hardware used:

● MATLAB 7.8 R2009a


● Personal Computer (32/62 bits)

Introduction to MATLAB : MATLAB (matrix laboratory) is a fourth-generation


high-level programming language and interactive environment for
numerical computation. visualization and programming.

After logging into your account, you can enter MATLAB by double-clicking
on the MATLAB shortcut icon (MATLAB 7.8.0) on your Windows desktop:
When you start MATLAB, a special window called the MATLAB desktop
appears. The desktop is a window that contains other windows. The major
tools within or accessible from the desktop are:

• Command Window

• Command History

• Editor Window

• Workspace

• Current Directory

• Help Browser

3
Figure 1.1: Command Window

Figure 1.2: Editor Window

4
MATLAB is widely used as a computational tool in science and engineering
encompassing the fields of physics, chemistry, math and all engineering
streams. It is used in a range of applications including-

• Signal Processing and Communications

• Image and Video Processing

• Control Systems

• Test and Measurement

• Computational Finance

• Computational Biology

Steps to MATLAB program: 1. Start the MATLAB program.

2. Open new M-file

3. Type the program

4. Save in current directory

5. Compile and Run the program

6. If any error occurs in the program correct the error and run it again

7. For the output see command window Figure window

8. Stop the program.

Control system Toolbox: Control System Toolbox is a package for Matlab


consisting of tools specifically developed for control applications. The
package offers data structure to describe common system representation
such as space state models and transfer functions as well as tools for
analysis and design of control systems.

5
Dynamic System Models: Represent Simple and Complex dynamics
systems, discretize models and reduce model order.

Figure 1.3: LTI Viewer

Control System ToolBox

6
Figure 1.4: Control system toolbox (SISO)

Experiment No. 2
Object: Determine transpose inverse values of given matrix.

Software/Hardware used:

● MATLAB 7.8 R2009a


● Personal Computer

Steps to MATLAB Program:

1. Start the MATLAB program.


2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.

Matlab Code:
X = [1 0 2; -1 5 0; 0 3 -9]
Y = inv(X)
transpose(X)

Results:

X =

1 0 2

-1 5 0

0 3 -9

7
Y =

0.8824 -0.1176 0.1961

0.1765 0.1765 0.0392

0.0588 0.0588 -0.0980

ans =

1 -1 0

0 5 3

2 0 -9

8
Experiment No. 3

Object: Plot the pole-zero configurations in s-plane for the given transfer function

H(s)=(2S2+5S+1)/(S2+3S+5).

Software/Hardware used:

● MATLAB 7.8 R2009a


● Personal Computer

Steps to MATLAB Program:

1. Start the MATLAB program.


2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.

MATLAB Code:

H = tf([2 5 1],[1 3 5]);


pzmap(H)
grid on

Result:

9
Thus the MATLAB Program to plot the pole zero mapping in s-plane using
MATLAB function is written and the results are successfully obtained.

10
Experiment No. 4

Object: Determine the transfer function for closed loop system.

Software/Hardware used:

● MATLAB 7.8 R2009a


● Personal Computer

Steps to MATLAB Program:

1. Start the MATLAB program.


2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.

MATLAB Code:

K=2
G=tf([1 2],[1 0.5 3])
H=feedback(G,K)
H2=G/(1+G*K)
zpk(H2)

Results:
K =

Transfer function:
s + 2
---------------

11
s^2 + 0.5 s + 3

Transfer function:
s + 2
---------------
s^2 + 2.5 s + 7

Transfer function:
s^3 + 2.5 s^2 + 4 s + 6
-----------------------------------
s^4 + 3 s^3 + 11.25 s^2 + 11 s + 21

Zero/pole/gain:
(s+2) (s^2 + 0.5s + 3)
---------------------------------
(s^2 + 0.5s + 3) (s^2 + 2.5s + 7)

>>

12
Experiment No. 5
Object: Plot the unit step response, impulse response of transfer function.

Software/Hardware used:

● MATLAB 7.8 R2009a


● Personal Computer

Steps to MATLAB Program:

1. Start the MATLAB program.


2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.

MATLAB Code:

H= tf([8 18 32], [1 6 14 24])


subplot (2,1,1)
step(H)
hold on
subplot (2,1,2)
impulse(H)
clf
t=0:0.01:4;
u=sin(10*t);
lsim(H,u,t)

Result:

13
Experiment No. 6
Object: Plot root locus of given transfer function.

Software/Hardware used:

● MATLAB 7.8 R2009a


● Personal Computer

Steps to MATLAB Program:

1. Start the MATLAB program.


2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.

MATLAB Code:

H=tf ([3 5 7],[1 2 2.5 4])


rlocus(H)
grid on

Result:

14
Experiment No. 7

Object: Plot bode plot of given transfer function and find phase and gain margin

Software/Hardware used:

● MATLAB 7.8 R2009a


● Personal Computer

Steps to MATLAB Program:

1. Start the MATLAB program.


2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again

15
7. For the output see command window\ Figure window
8. Stop the program.

MATLAB Code:

H=tf([8 18 32],[1 6 14 24])


bode(H)
grid on%%%%%%%%%%%%%%

Result:

Transfer function:
8 s^2 + 18 s + 32
-----------------------
s^3 + 6 s^2 + 14 s + 24

>>

16
Experiment No. 8

Object: Plot Nyquist plot of given transfer function.

Software/Hardware used:

● MATLAB 7.8 R2009a


● Personal Computer

Steps to MATLAB Program:

1. Start the MATLAB program.


2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.

MATLAB Code:

s=tf('s')
G=-((2*s+1)/(s^2+3*s+2))
k=0.5
T=feedback(G*k,1)
nyquist(T)
grid on
axis([-2 0 -1 1])

Result:

Transfer function:

17
s
Transfer function:
-2 s - 1
-------------
s^2 + 3 s + 2

k =

0.5000

Transfer function:
-s - 0.5
---------------
s^2 + 2 s + 1.5

>>

Experiment No. 9

Object: Create the state space model of a linear continuous system.

Software/Hardware used:

● MATLAB 7.8 R2009a


● Personal Computer

Steps to MATLAB Program:

1. Start the MATLAB program.


2. Open new M-file
3. Type the program
4. Save in current directory

18
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.

MATLAB Code:

J = [6 -4 -3; -5 10 -3; -3 -3 8];


F = 0.2*eye(3);
A = -J\F;
B = inv(J);
C = eye(3);
D = 0;
sys = ss(A,B,C,D)

Result:

a =
x1 x2 x3
x1 -0.1495 -0.08632 -0.08842
x2 -0.1032 -0.08211 -0.06947
x3 -0.09474 -0.06316 -0.08421

b =
u1 u2 u3
x1 0.7474 0.4316 0.4421
x2 0.5158 0.4105 0.3474
x3 0.4737 0.3158 0.4211

c =
x1 x2 x3
y1 1 0 0
y2 0 1 0
y3 0 0 1

19
d =
u1 u2 u3
y1 0 0 0
y2 0 0 0
y3 0 0 0

Continuous-time model.
>>

Experiment No. 10

Object: Determine the state space representation of the transfer function.

Software/Hardware used:

● MATLAB 7.8 R2009a


● Personal Computer

Steps to MATLAB Program:

1. Start the MATLAB program.


2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program

20
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.

MATLAB Code:

H = [tf([1 1],[1 3 3 2]) ; tf([1 0 3],[1 1 1])]


sys = ss(H)
size(sys)
sys = ss(H,'minimal')
size(sys)

Result:

Transfer function from input to output...


s + 1
#1: ---------------------
s^3 + 3 s^2 + 3 s + 2

s^2 + 3
#2: -----------
s^2 + s + 1

a =
x1 x2 x3 x4 x5
x1 -3 -1.5 -1 0 0
x2 2 0 0 0 0
x3 0 1 0 0 0
x4 0 0 0 -1 -1
x5 0 0 0 1 0

21
b =
u1
x1 1
x2 0
x3 0
x4 2
x5 0

c =
x1 x2 x3 x4 x5
y1 0 0.5 0.5 0 0
y2 0 0 0 -0.5 1

d =
u1
y1 0
y2 1

Continuous-time model.
State-space model with 2 outputs, 1 inputs, and 5 states.

a =
x1 x2 x3
x1 -1.759 -0.9983 0.3109
x2 -0.2439 -1.281 -1.018
x3 -0.05064 1.077 0.03966

b =
u1
x1 0.2105
x2 2.226
x3 0.03609

22
c =
x1 x2 x3
y1 -0.1494 0.009761 0.2694
y2 0.1787 -0.4801 0.8588

d =
u1
y1 0
y2 1

Continuous-time model.
State-space model with 2 outputs, 1 inputs, and 3 states.
>>

Experiment No. 11

Object: Determine the steady state errors of a given transfer function.

Software/Hardware used:

● MATLAB 7.8 R2009a


● Personal Computer

Steps to MATLAB Program:

1. Start the MATLAB program.


2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program

23
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.

MATLAB Code:
s = tf('s');
G = (4/(s+2));
T = feedback(G,(2/s+4));
t = 0:0.1:25;
u = t;
[y,t,x] = lsim(T,u,t);
plot(t,y,'y',t,u,'m')
xlabel('Time (sec)')
ylabel('Amplitude')
title('Input-purple, Output-yellow')

Result:

24
Experiment No. 12

Object: Determine the time response of the given system subjected to any arbitrary
input.

Software/Hardware used:

● MATLAB 7.8 R2009a


● Personal Computer

Steps to MATLAB Program:

1. Start the MATLAB program.


2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.

MATLAB Code:

sys = tf(3,[1 2 3])


t = 0:0.04:8; % 201 points
u = max(0,min(t-1,1));
lsim(sys,u,t)
grid on

y = lsim(sys,u,t);
size(y)

Result:

Transfer function:

25
3
-------------
s^2 + 2 s + 3

ans =

201 1

>>

26

You might also like