Practice 1: Introduction To Matlab. Control Toolbox: Objective

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Practices of Linear Multivariable Control Systems 2020/2021

PRACTICE 1: INTRODUCTION TO MATLAB. CONTROL TOOLBOX

The MATLAB (Matrix Laboratory) environment is an interactive software oriented to carry out technical
and scientific computations. This language is very easy to use and powerful when dealing with matrices.
The graphical visualization utilities are impressive and flexible. MATLAB has outstanding merits in
scientific computation and graphical visualization, compared with other software packages. MATLAB has
now become the most used software in the field of control systems analysis and design, among other
engineering and non-engineering areas. The MATLAB is composed by numerous toolboxes and we will be
focusing in Control Toolbox.

OBJECTIVE

The main objectives of this practice are:

• To provide the student the fundamentals of MATLAB as well as to explain its usage and
recommendations of programming.
• To practice the previous control knowledge solving some elemental problems related with systems
dynamics.

EXERCISES

Exercise 1. Operation between matrices. Considering the matrices:

 1 2 4  2 2 4
   
A= 7 8 9  , B =  7 3 5
 4  21 6 7 
 21 6   

Compute the following operations indicating the used commands:

Sum of two first columns of A

Sum of two first columns of B

Square of matrix A

Square of the components of matrix B

Inverse of matrix A

Pseudoinverse of matrix A

Product of matrices A and B

1
Practices of Linear Multivariable Control Systems 2020/2021

Which is the dimension of A?

Exercise 2. Trigonometric Matlab functions. Indicate the obtained value after carrying out the
following operations using the suitable commands.

cos(30º)

sin(30º)

cos2(30º)+sin3(40º)

Exercise 3. Division between matrices. Considering the previous matrices A and B. By the following
command, what operations are taken out? Which are the results?

A/B

A\B

Exercici 4. Matlab operations. By the following command, what operations are taken out?

det(A)

A’

diag(A)

triu(A)

tril(A)

size(A)

Compute these operations with the previous matrix A and matrix B.

Exercise 5. To visualize and to erase variables. Write the Matlab commands that: a) erase a variable, b)
erase all the variables, c) close all the figures.

Exercise 6. Computing matrices. Compute: (a) a matrix of zeros with 3 rows and 4 columns, (b) an identity
matrix with 4 rows and 3 columns, (c) an identity matrix 3×3. NOTE: Use the commands: zeros, ones, eye.

Exercise 7. Graphics. Plot the curves y=x.sin(x), y =x, respect the axis x in the interval [0, 1]. Show the
graphics with different color or line style, add axis labels and add a legend to the graphs (using title, xlabel,
ylabel, legend and grid).

Exercise 8. Define a vector x that ranges from 0 to 100 by steps of size 0.5. Plot sin(x) and 1+cos(x) on
the same graph. Represent the sine curve with a ‘dashed’ line and the cosine curve by a ‘dashdot’. Also
label the graph and save it as a script.

2
Practices of Linear Multivariable Control Systems 2020/2021

Exercise 9. Polynomials. Answer the questions: a) Represent the following polynomial 𝑠𝑠 5 + 3𝑠𝑠 3 +
7𝑠𝑠 2 + 3𝑠𝑠 + 4 and find its roots. (NOTE: Use the command roots) b) Considering the roots of the
polynomial , -3, -8, -5, represent this polynomial. (NOTE: Use the command poly).

Exercise 10. Creating models. Create the following transfer function

(𝑠𝑠 + 2)
𝐺𝐺(𝑠𝑠) =
𝑠𝑠 2 + 4𝑠𝑠 + 3

a) Using polynomials coefficients (using tf) and zeros, poles and gain (using zpk).
b) Which is the canonical gain? (using dcgain).
c) Include a delay of 0.5 s in the previous transfer function.

Exercise 11. Transfer function. Type with Matlab the following transfer functions

𝑠𝑠 3 − 𝑠𝑠 + 2
𝐺𝐺1(𝑠𝑠) = 5
𝑠𝑠 + 2𝑠𝑠 4 + 3𝑠𝑠 3 − 6𝑠𝑠 2 + 2𝑠𝑠 + 1
3
𝐺𝐺2(𝑠𝑠) =
𝑠𝑠 2 + 7𝑠𝑠 + 6
7(𝑠𝑠 + 1)(𝑠𝑠 − 2)
𝐺𝐺3(𝑠𝑠) = 𝑒𝑒 −4.7𝑠𝑠
(𝑠𝑠 + 5)(𝑠𝑠 + 4)(𝑠𝑠 + 3)

4
𝐺𝐺4(𝑠𝑠) =
(𝑠𝑠 − 2)(𝑠𝑠 + 3)

𝑠𝑠 2 − 2𝑠𝑠 + 2
𝐺𝐺5(𝑠𝑠) =
(𝑠𝑠 + 2)(𝑠𝑠 + 3)(𝑠𝑠 + 4)

using zpk or tf according the expression cited previously. If the transfer function is in polynomial form
then convert this expression to zeros and poles and viceversa.

3
Practices of Linear Multivariable Control Systems 2020/2021

Exercise 12. Manipulating blocks (I). Obtain the equivalent transfer function of the following block
scheme.

1 1 0.1
with 𝐺𝐺1(𝑠𝑠) = , 𝐺𝐺2(𝑠𝑠) = , 𝐺𝐺3(𝑠𝑠) = and H(s) = 10.
𝑠𝑠+4 𝑠𝑠 𝑠𝑠+2

NOTE: Use the commands: series, parallel, feedback.

Exercise 13. Manipulating blocks (II). Obtain the equivalent transfer function of the following block
scheme:

with
7𝑠𝑠+4 3 5
𝐺𝐺1(𝑠𝑠) = 3.5 , 𝐺𝐺2(𝑠𝑠) = , 𝐺𝐺3(𝑠𝑠) = and 𝐺𝐺4(𝑠𝑠) =
𝑠𝑠3 +2𝑠𝑠2 +3𝑠𝑠+5 𝑠𝑠+4 2𝑠𝑠+4

Exercise 14. Manipulating blocks (III). Obtain the equivalent transfer function of the following block
scheme:

3 𝑠𝑠+4 𝑠𝑠+4
with 1(𝑠𝑠) = , 𝐺𝐺2(𝑠𝑠) = and 𝐺𝐺3(𝑠𝑠) = .
𝑠𝑠+7 𝑠𝑠2 +3𝑠𝑠+1 𝑠𝑠+3

4
Practices of Linear Multivariable Control Systems 2020/2021

Exercise 15. Step response. Find the poles of G(s)=(3s+1)/(s^2+2s+1) and plot the time response of the
system described by G(s) with a step change of magnitude 2. NOTE: Use the commands: tf, pole,
step.

2𝑠𝑠+3
Exercise 16. Characteristics of step response. Plot the step response of the system: 𝐺𝐺1(𝑠𝑠) = , and
𝑠𝑠2 +3𝑠𝑠+5
obtain the settling time, overshoot, rise time and steady state click with the mouse right button on the
corresponding plot window with Matlab. Plot in the same graphic the step response of the system 𝐺𝐺2(𝑠𝑠) =
2𝑠𝑠+3
and obtain the settling time, rise time, steady-state and overshoot, also. Are the systems overdamped,
𝑠𝑠2 +𝑠𝑠+5
underdamped or critically damped? Use the commands: tf, step.

𝑠𝑠+3
Exercise 17. Time response. Plot the response of the following system 𝐺𝐺(𝑠𝑠) = when the input is
𝑠𝑠2 +2𝑠𝑠+7
𝑥𝑥(𝑡𝑡) = 4 + 3𝑡𝑡 + 2.5𝑡𝑡 2 . NOTE: Use the commands: tf, impulse.

Exercise 18. Accuracy. Obtain the closed-loop steady-state error of the following open-loop transfer
𝑠𝑠+5 5
functions: 𝐿𝐿(𝑠𝑠) = 𝐺𝐺(𝑠𝑠)𝐻𝐻(𝑠𝑠) = and 𝐿𝐿1 (𝑠𝑠) = 𝐺𝐺1 (𝑠𝑠)𝐻𝐻1 (𝑠𝑠) = 𝑠𝑠
𝑠𝑠(𝑠𝑠2 +3𝑠𝑠+4) 𝑠𝑠(𝑠𝑠+1)( +1)
3

for the different inputs: step, ramp and parabola: a) analytically and b) with Matlab (using command
dcgain).

𝑠𝑠+4
Exercise 19. Stability. Study the stability of the following control systems: 𝑊𝑊1 (𝑠𝑠) = ,
𝑠𝑠5 +2𝑠𝑠4 +3𝑠𝑠3 +9𝑠𝑠2 +2𝑠𝑠+10
𝑘𝑘 𝑠𝑠+2
𝑊𝑊2 (𝑠𝑠) = and 𝑊𝑊3 (𝑠𝑠) = through the roots of the system. Use the
𝑠𝑠5 +2𝑠𝑠4 +3𝑠𝑠3 +9𝑠𝑠2 +2𝑠𝑠+10 𝑠𝑠3 +2𝑠𝑠2 +𝑠𝑠+2
commands: roots.

Exercise 20. Stability. Study the stability of the closed-loop transfer function, 𝐿𝐿(𝑠𝑠) = 𝐺𝐺(𝑠𝑠)𝐻𝐻(𝑠𝑠) =
6
. Use the commands: roots.
(𝑠𝑠−1)(𝑠𝑠+2)

You might also like