0% found this document useful (0 votes)
12 views26 pages

MATLAB Control System Practical Guide

This document appears to be the index page of a practical file submitted by Aviral Chaurasia, a third year ECE student, to their professor Dr. Aneesh. The index lists 12 experiments conducted using MATLAB to analyze control systems and signals. The experiments include determining matrix properties, plotting pole-zero configurations, deriving transfer functions, modeling systems, and analyzing time and frequency responses through step responses, root loci, and Bode and Nyquist plots. Sample code and results are provided for some of the experiments.

Uploaded by

Aviral Chaurasia
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)
12 views26 pages

MATLAB Control System Practical Guide

This document appears to be the index page of a practical file submitted by Aviral Chaurasia, a third year ECE student, to their professor Dr. Aneesh. The index lists 12 experiments conducted using MATLAB to analyze control systems and signals. The experiments include determining matrix properties, plotting pole-zero configurations, deriving transfer functions, modeling systems, and analyzing time and frequency responses through step responses, root loci, and Bode and Nyquist plots. Sample code and results are provided for some of the experiments.

Uploaded by

Aviral Chaurasia
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

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

[Link]. 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

Common questions

Powered by AI

To determine the steady state error of a control system in MATLAB, you model the system using transfer functions and apply feedback using the 'feedback' function. The steady state error is analyzed through graphical outputs or computations based on the final value theorem. It assumes the system reaches a steady state and uses inputs that are simplified mathematical models, such as step, ramp, or parabolic inputs .

Nyquist plots in control systems are used to assess stability and gain margins by representing the frequency response of open-loop systems. MATLAB assists by enabling the plotting via the 'nyquist' function, wherein engineers can visualize the frequency response in the complex plane and interpret the encirclements of the critical point (-1,0) to determine system stability based on Nyquist stability criterion .

Plotting pole-zero configurations in MATLAB requires defining the transfer function using 'tf' and employing 'pzmap' to visualize the poles and zeros on the s-plane. This process is significant as it allows engineers to identify system characteristics like stability margins, potential resonances, and natural frequencies, aiding in the design and analysis of control systems .

To compute the inverse of a matrix in MATLAB, you first start MATLAB and open a new M-file, type the program involving the inverse operation using the 'inv()' function, and save it in the current directory. Common errors might include attempting to invert a non-square or singular matrix, which could result in singular matrix warnings or errors .

The Control System Toolbox in MATLAB provides tools specifically developed for control applications. It offers data structures to describe common system representations like state-space models and transfer functions. Moreover, it includes functionalities for analysis and design of control systems, enabling engineers to model dynamic systems, discretize models, reduce model order, and assess system behavior through tools like the LTI Viewer and SISO Design Tool .

MATLAB facilitates the visualization of step and impulse responses of a linear system using its Control System Toolbox. Implementing this involves creating a MATLAB script that defines the transfer function of the system using the 'tf' function, and then using 'step' and 'impulse' commands to plot the respective responses. These plots provide insights into system behavior and stability .

In MATLAB, root locus is implemented by defining the transfer function and using the 'rlocus' command to plot roots of the characteristic equation as system parameters vary. This visualization helps in understanding how poles of a system move in the s-plane with changes in system gain, thus aiding in analyzing stability and designing controllers to achieve desired closed-loop system performance .

Creating a state space model in MATLAB involves defining matrices 'A', 'B', 'C', and 'D' corresponding to the state equations using commands like 'ss'. This representation is useful as it accommodates multiple-input and multiple-output systems and provides a unified framework for analyzing and designing control systems, capturing both transient and steady-state behaviors efficiently .

MATLAB models the time response to arbitrary inputs through the 'lsim' function, which simulates response to non-standard inputs by integrating the system equations. Insights gained include dynamic behavior observations, such as overshoot, settling time, and system resilience to complex inputs, which are critical for designing robust control systems .

To plot a Bode plot in MATLAB, you need to define the transfer function using 'tf' and then use the 'bode' command. The gain margin and phase margin are extracted from the plot, where gain margin indicates the amount of gain increase required to make the system unstable, and phase margin shows the additional phase lag needed for instability. These margins relate to system stability robustness .

You might also like