Вы находитесь на странице: 1из 19

1

UNIVERSITY OF CAPE TOWN

Evaluation of
Matlab/Simulink
Functionality for Control
Systems Design
EEE4013F – Control Systems

Jeanne Fourie
FRXJEA004

4/4/2011
2

Contents
1. Introduction .................................................................................................................................... 3
2. Matlab and Simulink Defined.......................................................................................................... 3
2.1 Matlab ........................................................................................................................................... 3
Figure 1: Typical Matlab screen ...................................................................................................... 4
2.2 Simulink ......................................................................................................................................... 4
3. Matlab/Simulink in Control System Design .................................................................................... 4
Figure 2: Control System ................................................................................................................. 4
4. Model Analysis ................................................................................................................................ 5
4.1 Laplace Transforms ....................................................................................................................... 5
Figure 3: Matlab code for Laplace Transformation ........................................................................ 6
Figure 4: Command window display for Laplace Transformation .................................................. 6
4.2 Linear Time-Invariant Systems ...................................................................................................... 7
Figure 5: Matlab code for LTI .......................................................................................................... 7
Figure 6: Command window display for LTI .................................................................................... 8
4.4 Root Locus Plots ............................................................................................................................ 9
Figure 7: Root Locus Plot ................................................................................................................ 9
5. Control Configuration Selection.................................................................................................... 10
5.1 SISO Tool ..................................................................................................................................... 10
Figure 8: SISO tool ......................................................................................................................... 10
5.2 Model Analysis and Controller Design Tools .............................................................................. 11
Table 1: Selected Model Analysis and Controller Design Tools .................................................... 11
6. System Simulation and Evaluation ................................................................................................ 11
6.1 Time and Frequency Response ................................................................................................... 11
Table 2: Matlab Response Plot Commands .................................................................................. 11
Figure 9: Step Response of Transfer Function .............................................................................. 12
Figure 10: Bode Plot of Transfer Function .................................................................................... 12
6.2 Simulink ....................................................................................................................................... 13
Figure 11: Block Diagram of Closed Loop Control System ............................................................ 13
Figure 12: Simulink-Created Block Diagram for Water Tank System ............................................ 13
7. Case Study ..................................................................................................................................... 14
7.1 Problem description .................................................................................................................... 14
7.2 Nominal Model ........................................................................................................................... 14
Table 3: Model States, Inputs and Outputs .................................................................................. 14
3

7.3 System Analysis ........................................................................................................................... 14


Figure 13: Command Window Display of Eigenvalues.................................................................. 14
Figure 14: Pole Zero Map .............................................................................................................. 15
Figure 15: System Impulse Response Over Eight Hundred Seconds ............................................ 15
Figure 16: Bode Diagram............................................................................................................... 16
7.4 Controller Design ........................................................................................................................ 16
Figure 17: Subsystem Root Loci .................................................................................................... 16
Figure 18: Subsystem Closed Loop Impulse Response ................................................................ 17
8. Evaluation ..................................................................................................................................... 17
9. Conclusion ..................................................................................................................................... 17
10. Bibliography .............................................................................................................................. 18
Appendix A ............................................................................................................................................ 19

1. Introduction
Control engineering is a highly relevant field in many areas of technological advancement today. The
optimization of dynamic systems through control can lead to more efficient, less expensive, more
environmentally friendly and ultimately better behaved systems. Control theory can be applied to
systems ranging from kitchen appliances to military aircraft.

Designing the necessary control systems, however, can become complex. Luckily, there are many
tools available to simplify and improve the control system design process. One such tool is the
computational programme, Matlab and its simulation tool, Simulink.

This report will briefly describe and thus evaluate both Matlab and Simulink for control system
design purposes.

2. Matlab and Simulink Defined


2.1 Matlab
Matlab (the contracted form of Matrix Laboratory) is widely used as an engineering, scientific and
economic computational tool1. It possesses a wide range of features to aid with mathematical
modeling. It facilities function plotting, matrix manipulation, data handling, algorithm
implementation, can create user interfaces and is capable of interfacing with programmes written in
other coding languages2. Furthermore, it is possible to integrate various toolboxes for specific
purposes into Matlab as and when they are needed.

1
Antonios Andreatos and Anastasios Zagorianos, Matlab GUI Application for Teaching Control Systems, p. 1.
2
Stefan Steinhaus, Comparison of mathematical programs for data analysis, pp. 1-37.
4

Figure 1: Typical Matlab screen

2.2 Simulink
Simulink is an integrated Matlab tool that allows dynamic system modeling. It builds on the basis
provided by Matlab’s matrix manipulation structures to present functions specifically suited to
control system design. The Simulink Control System Toolbox, as such, utilises various prewritten
algorithms in the form of m files (Matlab script files) to allow its user to implement standard control
procedures3.

3. Matlab/Simulink in Control System Design


A control system is a selected arrangement of components that provides a desired output for a
certain input or range of inputs4.

Figure 2: Control System

3
The Math Works Inc. Control System Toolbox User's Guide, p. 2.
4
Rao V. Dukkipati, Analysis and Design of Control Systems using MATLAB, p. 1.
5

The general control system design procedure follows the subsequent simplified steps5:

1. Understand the behaviour of the system in question and the control objectives
2. Model the system and simplify this model
3. Analyse the model
4. Select the appropriate control configuration
5. Design the necessary controller
6. Simulate and evaluate the controlled system
7. Implement and evaluate the controlled system

The steps mentioned above in blue can be accomplished using Matlab/Simulink as tools. Some of
these tools and features will be discussed in subsequent sections. The features described below
should not be regarded as an exhaustive representation of Matlab and Simulink’s capabilities in
control system design.

4. Model Analysis
There are three types of models that are important in control system design6:

 Calibration model: a detailed mathematical representation of the dynamic system, possibly


including parameters that have no bearing on its control
 Nominal model: a simplified mathematical representation of the dynamic system, including
only the elements that influence its control.
 Error model: the difference between the calibration and nominal models represent the error
model.

As this report focuses on Matlab/Simulink functionality is control system design it will not elaborate
in detail on Matlab’s value in dynamic system modeling in general. It suffices to say that Matlab,
with its wide range of computational, mathematical and data handling functions is an ideal tool in
the analysis of system models. This section will deal with the development and analysis of the
nominal model.

In terms of control model analysis, Matlab presents many useful features. Some of these features
will be described below.

4.1 Laplace Transforms


Having modeled the system in question using engineering methods such as force analysis, one is
most often left with a differential equation relating system dynamics to time. By using linear variable
change Laplace transformations one can transform complicated real time dependent differential
equations into functions of the complex variable s. The transformed version is much simpler to work
with and forms the foundation of control system design. The Laplace transform is defined as:

𝐿 𝑓 𝑡 =𝐹 𝑠 = 𝑒 −𝑠𝑡 𝑓 𝑡 𝑑𝑡
0

5
Dang Doan, Control System Design Steps, p.1.
6
M.S. Tsoeu, M. S. LECTURE NOTES: EEE4013F - Control Systems, pp. 12- 13.
6

Although one is not necessarily required to evaluate integrals to perform the transformation –
extensive lookup tables are available – calculating Laplace transformations is tedious nonetheless.

Matlab, however, has useful Laplace transform capabilities. L = laplace(F)represents the


Laplace transform of a function, F7.

The following code in Figure 3 is an example of the Laplace transform feature. It computes the
Laplace transform of 𝐹 = 3.5𝑡𝑒 −2𝑡 + 1.25𝑒 −2𝑡 , simplifies it and then uses the novel pretty
function to display it as a fraction. Figure 4 shows the answers returned in the command window.

Figure 3: Matlab code for Laplace Transformation

Figure 4: Command window display for Laplace Transformation


If one wanted to obtain the inverse Laplace transform of a function, the ilaplace command acts
in a similar manner as described above.

7
MathWorks, Symbolic Math Toolbox: laplace
7

4.2 Linear Time-Invariant Systems


Linear Time-Invariant (LTI) systems are often encountered when dealing with system models and
control theory. An LTI system is defined by characteristics of linearity (a system’s input and output
are related by a linear map) and time-invariance (the output for a certain time period does not
depend on when the time period begins).

Matlab presents many ways of dealing with LTI’s8. Firstly, it features various ways of setting up the
system equation in question. SYS = tf(num,den) returns a transfer function, SYS =
zpk(z,p,k) a zero/pole/gain system, SYS = ss(a,b,c,d)a state space setup and SYS =
frd(response, frequencies)returns frequency response data.

The following code in Figure 6 illustrates the transfer function and zero/pole/gain features by
employing an example system,

𝑠+2
𝑠2 + 2𝑠 − 3

Figure 5: Matlab code for LTI

8
The Math Works Inc. Control System Toolbox User's Guide, p. 1.3.
8

The following answers are returned in the Command Window:

Figure 6: Command window display for LTI

An alternative method for finding the zero/pole/gain output is to use the command [z, p, k] =
tf2zp(num,den)which returns z = zeros, p = poles and k = gain in the command
window9.

If one wishes to split the system into partial fractions for analysis purposes, the command [r,p,k]
= residue(num,den) can be used to return r, p and k in the following formula10:

𝑁(𝑠) 𝑟(1) 𝑟(𝑛)


=𝑘 𝑠 + + ⋯+
𝐷(𝑠) 𝑠 − 𝑝(1) 𝑠 − 𝑝(𝑛)

Multiple Input, Multiple Output (MIMO) systems can be created similarly as well as LTI arrays for
simple manipulation of a set of models. The command set(SYS) returns an assortment of
information about a system, such as its name, sample time, etc.11

9
Rao V. Dukkipati, Analysis and Design of Control Systems using MATLAB, p. 76.
10
Rao V. Dukkipati, Analysis and Design of Control Systems using MATLAB, p. 75.
11
The Math Works Inc. Control System Toolbox User's Guide, p. 1.5 -1.6.
9

4.4 Root Locus Plots


Root locus plots are often employed in control system design. Root loci offer insight into how
changing system parameters will influence speed, stability, etc. Matlab offers easy root locus
plotting tools.

Using the command rlocus(SYS), where SYS refers to the following transfer function:

s+7

---------

s^2 + 5 s

the plot show below in Figure 7 can be obtained.

Figure 7: Root Locus Plot

The Root Locus Design GUI can be accessed by typing rltool in the command window. This
graphic user interface allows control system design using root loci12.

12
The Math Works Inc. Control System Toolbox User's Guide, p. 1.23.
10

5. Control Configuration Selection


This section deals with some of the methods and tools available in Matlab/Simulink to aid the
selection of a suitable control configuration for a dynamic system.

5.1 SISO Tool


SISO Tool is useful for analysis of Single Input, Single Output systems using root locus plots. It can be
accessed by typing sisotool. The Control and Estimation Manager window will then launch.
Systems that have already been created can be imported and poles and zeros can then be placed on
the screen and the new root loci and bode plots immediately seen. Figure 8 illustrates the SISO tool.

Figure 8: SISO tool


11

5.2 Model Analysis and Controller Design Tools


Apart from the features mentioned above, Matlab contains many further model analysis as well as
dedicated controller design tools and features. Some of these tools are mentioned in this section.

Table 1: Selected Model Analysis and Controller Design Tools


Matlab Command Description
damp(SYS) Damping response and natural frequency

pole(SYS), eig(SYS) Poles (or eigenvalues)

pzmap(SYS) Pole Zero plot

rlocfind Interactive gain selection plot

place Pole placement (MIMO)

lqr Linear quadratic optimal gain for continuous


systems
kalman Kalman estimator

6. System Simulation and Evaluation


Many of the tools mentioned in preceding sections can be of use in the eventual simulation of the
controlled system. The tools mentioned in this section, however, are particularly apt.

6.1 Time and Frequency Response


When analyzing models for control purposes, one is often interested in a system’s response to
certain inputs. Matlab provides simple plotting tools that help visual the system’s response without
complicated manual mathematics and plotting.13 Some of these tools are mentioned in Table 2
below.

Table 2: Matlab Response Plot Commands


Matlab Command Description Notes
step(SYS) Step response

impulse(SYS) Impulse response

initial(SYS,x0) Non-driven response to initial Only supported for steady


condition state systems
lsim(SYS,u,t,x0) Response to input, u

bode(SYS) Bode plot

13
The Math Works Inc. Control System Toolbox User's Guide, p. 1.14.
12

nyquist(SYS) Nyquist plot

nichols(SYS) Nichols plot

sigma(SYS) Singular value plot

freqresp(SYS,w) Complex frequency response Returns answer in


command window

The following figures illustrate some of the commands in table 1 above. (Note: the transfer function
defined as TF in Figure 6 of Section 4.2 is the system plotted in Figures 9 and 10)

Figure 9: Step Response of Transfer Function

Figure 10: Bode Plot of Transfer Function


13

6.2 Simulink
Simulink offers various tools for representing and dealing with control systems. Systems can be
represented using block diagrams. Figure 11 is an example of a block diagram representing a closed
loop system.

Figure 11: Block Diagram of Closed Loop Control System14

Block diagrams such as these can be constructed using Simulink and hence their properties can be
evaluated. In order to access the Simulink tool, type simulink in the command window. An
example of a block diagram created with Simulink created for a water tank system is shown in Figure
12.

Figure 12: Simulink-Created Block Diagram for Water Tank System

LTI’s that have already been set up can be imported into Simulink blocks by typing ltiblock into
the command window.

14
Rao V. Dukkipati, Analysis and Design of Control Systems using MATLAB, p. 4.
14

7. Case Study
In order to illustrate Matlab/Simulink’s use in control system design this section considers a case
study. The control system in question is to be designed for an aircraft yaw damper15. See Appendix A
for Matlab code.

7.1 Problem description


A yaw damper is a device that reduces oscillations due to Dutch roll in aircraft. Dutch roll refers to
combined lateral and directional oscillations – rolling and yawing16. The damping ratio, ζ is to be
greater than 0.35 and the natural frequency, ωn less than 1 rad/sec.

7.2 Nominal Model


The nominal model for the aircraft can be represented by four matrices. These represent the states,
inputs and outputs of the system.

Table 3: Model States, Inputs and Outputs


States Inputs Outputs
beta (sideslip angle) rudder yaw
yaw aileron bank angle
roll
phi (bank angle)

The state space model matrices are printed in the command window. (Run the code in Appendix A)

7.3 System Analysis


Matlab code is written to find and display the system’s eigenvalues in the command window and
plot the poles (eigenvalues) and zeros in the s-plane.

Figure 13: Command Window Display of Eigenvalues

15
The Math Works Inc. Control System Toolbox User's Guide, pp. 9.3-9.19. This case study, including all models
and values, is extracted from this work. Code has been adapted slightly to suit the purposes of this report.
16
Aviation Glossary, Aviation Glossary: Dutch Roll.
15

Figure 14: Pole Zero Map


Figure 14 reveals slightly damped poles. This is consistent with Dutch roll mode in aircraft.

Conclusions as to potential control approaches can be drawn by plotting the step and impulse
responses of the open loop system.

Figure 15: System Impulse Response Over Eight Hundred Seconds

From Figures 15 it is apparent that the system is indeed lightly damped. As minimal oscillations are
to occur just after the impulse is applied it could be useful to look at the impulse response over a
smaller time frame. (Run the code in Appendix A for the graphs in Figure 15 over a 30 second period)
16

Yaw dampers are usually designed to feature the rudder as a control input and the yaw rate as a
sensed output. Plotting the Bode diagram for an input and output both equal to 1 provides the
following plot:

Figure 16: Bode Diagram


From Figure 16 it is apparent that there is a significant event at around ω = 1 rad/sec. Choose and
define the subsystem of interest as that from rudder to yaw rate.

7.4 Controller Design

Figure 17: Subsystem Root Loci

It is clear from Figure 17 that the system becomes unstable very quickly. The chosen subsystem used
negative feedback. Positive feedback would invert the root loci and stabilise the system. This
achieves a damping ratio of ζ = 0.45. Already this is closer to the objectives set for the controller.
17

One can thus define the closed loop system as the negative of the initially chosen system. Analysis of
the new closed loop system reveals that its impulse response (see Figure 18) is much more
satisfactory than the responses illustrated in Figure 15.

Figure 18: Subsystem Closed Loop Impulse Response

Although the control system still require much fine tuning and the control design process is not
terminated, this case study illustrates Matlab’s usefulness in control system design.

8. Evaluation
The above descriptions of features and tools, as well as the case study undertaken in Section 7,
reveal that Matlab/Simulink is a useful, user friendly computational tool with definite value in
control system design. Tasks necessary for control design but that are tedious or time consuming
when done manually can be carried out efficiently using the tools that Matlab/Simulink provides.

Furthermore, a study undertaken by Stefan Steinhaus, comparing the efficacy of various


mathematical computational tools rated Matlab very highly when compared to similar
programmes.17

9. Conclusion
The descriptions and case study above lead to the conclusion that Matlab and Simulink are useful,
effective tools in control system design. Various stages of the design process can be dealt with
through Matlab. It is the designer’s choice whether to use Matlab and Simulink as basic tools in low
level design or to exploit Matlab at its full computational power.

17
Stefan Steinhaus, Comparison of mathematical programs for data analysis,pp. 34-37.
18

10. Bibliography
Andreatos, Antonios S, and Anastasios D Zagorianos. "Matlab GUI Application for Teaching Control
Systems." Hellenic Air Force Academy. www.wseas.us/e-
library/conferences/2009/rodos/EDU/EDU32.pdf (accessed March 20, 2011).

Aviation Glossary. Aviation Glossary: Dutch Roll. 2011. http://aviationglossary.com/aircraft-terms-


definition/dutch-roll/ (accessed April 7, 2011).

Bodemann, Christian D, and Filippo De Rose. "The Successful Development Program with Matlab
Simulink in the Framework of ESA's ATV Project." Vega Group. http://www.vega-
group.com/assets/documents/10000421matlabsimulink.pdf (accessed April 5, 2011).

Doan, Dang. "Control System Design Steps." Scribd. April 13, 2007.
http://www.scribd.com/doc/86108/Control-System-Design-Steps (accessed April 6, 2011).

Dukkipati, Rao V. Analysis and Design of Control Systems using MATLAB. New Delhi: New Age
International (P) Limited, 2006.

Moler, Cleve. "The Growth of Matlab and The Math Works Over Two Decades." Cleve's Corner.
January 2006.
http://www.mathworks.com/company/newsletters/news_notes/clevescorner/jan06.pdf (accessed
April 5, 2011).

Nguyen, Tom. Matlab & Simulink: A Tutorial.


http://edu.levitas.net/Tutorials/Matlab/controlsys.html (accessed April 6, 2011).

Pal´ancz, B´ela, Zolt´an Beny´o, and Levente Kov´acs. "Product Review - Control Sysem Professional
Suite." Wolfram. IEEE Control Systems Magazine. April 2005.
library.wolfram.com/infocenter/articles/5629/csps_rev_ieeecsm0405.pdf (accessed April 4, 2011).

Princeton Satellite Systems. "Wind Turbine Control Toolbox for Matlab." Princeton Satellite Systems.
www.psatellite.com/wct/pdfs/techbrief.pdf - Similar (accessed March 20, 2011).

Steinhaus, Stefan. "Comparison of mathematical programs for data analysis." scientificweb. July 17,
2008. http://www.scientificweb.com/ncrunch/ncrunch5.pdf (accessed April 5, 2011).

The Math Works Inc. "Control System Toolbox User's Guide." MathWorks. 1999. http://www-
lar.deis.unibo.it/~lmarconi/files/control_tb.pdf (accessed March 17, 2011).

—. Symbolic Math Toolbox: laplace. 2011.


http://www.mathworks.com/help/toolbox/symbolic/laplace.html (accessed April 6, 2011).

Tsoeu, M. S. LECTURE NOTES: EEE4013F - Control Systems. PDF. University of Cape Town.
19

Appendix A
%--------------------------------------------------------------------------
%EEE4013F Reading Assignment.
%This code is an example of the use of Matlab in control system design by
%means of a case study. the case study deals with a yaw damper design for
%an aircraft.
%7 April 2011
%--------------------------------------------------------------------------
%NOTE: As this code plots various functions, only the last function will
%plot. To aid process speed the previous plots are commented out.
%Uncomment plots as necessary.
%--------------------------------------------------------------------------
clc
clear
%Setup aircraft model at MACH 0.8 and H = 40000ft
A = [-0.0558 -0.9968 0.0802 0.0415
0.5980 -0.1150 -0.0318 0
-3.0500 0.3880 -0.4650 0
0 0.0805 1.0000 0];
B = [ 0.0729 0.0000
-4.7500 0.00775
1.5300 0.1430
0 0];
C = [0 1 0 0
0 0 0 1];
D = [0 0
0 0];
%Define and specify state space model
states = {'beta' 'yaw' 'roll' 'phi'};
inputs = {'rudder' 'aileron'};
outputs = {'yaw' 'bank angle'};
sys = ss(A,B,C,D,'statename',states,...
'inputname',inputs,...
'outputname',outputs);
%Display space state model details
sys
%Display open loop eiegenvalues(poles) and plot in s-plane
damp(sys)
%pzmap(sys)
%Plot the open loop impulse response over 30 seconds
%impulse(sys,30)
%Plot Bode diagram
%bode(sys(1,1))
%Define subsystem from rudder to yaw rate
sys11 = sys(1,1);
%Plot subsystem's root loci
%rlocus(sys11)
%Positive feedback poles
[k,poles] = rlocfind(-sys11);
damp(poles)
%Define closed loop system
cl11 = feedback(sys11,-k);
%Display closed loop eigenvalues
damp(cl11)
%Plot closed loop impulse response
impulse(cl11)
%--------------------------------------------------------------------------
%End of code