UESTC4003 - Control Computer Lab Exercise 1

Hello, if you have any need, please feel free to consult us, this is my wechat: wx91due

UESTC4003 -  Control

Computer Lab Exercise 1

MATLAB for Control Engineering

1.0 Objectives

The primary aim of this class is to:

•   Setting up Control problems in MATLAB

•   Evaluate complex function via vectors

•   Create and analyse Root Locus plots

•   Create and analyse frequency domain plots

2.0     Basic MATLAB commands and their use

2.1       Use of MATLAB environment for elementary calculations

2.1.1    Fundamental expressions

Enter the following simple expression

>> a = 2+3

Always remember to press return key after typing. The result is assigned to variable “a”, i.e. a = 5.

Then try your own arithmetic expressions using the operators “ + ” , “ - ”, “ * ”,  “ / ”, “ ^ ”.

Use MATLAB to evaluate →  x  = 4/6 − √[2(3 + 8)]

2.1.2    Reassign Variables

Type who command to see a list of defined variables in alphabetical order,    and type one of these variables and press return to see its current value. Now reassign the value of that variable to a different value.

2.1.3    Predefined variables

MATLAB has several predefined variables.

i, j –  complex number. Try → (3-5j)+(4+2i)

pi   –  stands for π . Try → pi

Inf  –  stands for ∞ . Try → 5/0

NaN  –  stands for not a number. Try → 0/0

2.1.4    Built-in functions

MATLAB contains number of built-in functions to perform computations. Test below functions, where relevant use MATLAB help to understand formatting of each function (see section 2.3 regarding MATLAB help).

abs, sqrt, round, exp, log, sin, real

2.2       Edit previous commands

Use the cursor keys to edit (left/right arrow keys) and find previously entered commands (up/down arrow keys). Find “x” and change “6” to “a” .

2.3       MATLAB help

Entering “help” at the MATLAB prompt displays a list of MATLAB help topics. Type

>> help control

to see the table of contents of control system toolbox help.

2.4       Creating Script files

Script file contains series of MATLAB commands, where it is easier to use    script files rather than enter commands at the MATLAB prompt. Each script  file should have a name and an extension of “ .m” . Script file can be executed by entering the name of the file in the MATLAB environment.

Create a script file to estimate total surface area of a cylinder and save as “area_cylinder.m” . Don’t forget to define radius and height at the start.

2.5         General commands

clear all            All variables are removed from workspace

clear a b c        a, b and c variables are removed

clc                   Clears command window

c                      kills the current command execution

quit                  quit MATLAB

2.6       Vectors and Matrices

A row vector with 4 elements can be defined as below. >> A = [12 42 3 -27]

When element-by-element involve some mathematical operations, the operator is preceded by a dot, .e.g. A.*2

Convert 5oC, 10oC, 15oC, … , 50oC into Fahrenheit scale, convert all cases at once.

If elements are entered with a semicolon between the elements, then it becomes a column vector.

>> A = [12; 42; 3; -27]

In matrices elements in the same row separated with a space and different rows with a semicolon.

B= [2 3 -6; 4 8 1; -3 2 0]

Tests with the functions oneszeros and eye, and create 5 x 5 matrix with all its elements equal to 2.6.

3.0     Setting up control problems in MATLAB

Consider the system described by:

Define two row vectors to represent numerator polynomial and denominator

polynomial of the function G(s). Use “num” to represents the numerator polynomial and “den” to represent denominator polynomial. Use conv function to multiply

polynomials where relevant (hint: use help conv to see how conv works).  Now use printsys command to print transfer function as a ratio of the two

polynomials. Alternatively, tf function in MATLAB can be used to create the same transfer function. Plot the unit-step response of G(s).

Consider the below control system and assume K=1 and H(s)=1. Find the closed-loop transfer function with use of feedback function in MATLAB.

Also find the closed-loop transfer function when 

Now plot the step response for each case of H(s) when K =500.

Write G(s) manually in terms of its partial-fractions. Then use residue function in MATLAB to check the answers.

Now consider the below system.

Find the closed-loop transfer function (assuming K =1) using MATLAB and hence find the poles and zeros of the system.

Now recalculate the poles and zeros of the system, when

a)   K = 7.5

b)  K = 13

c)   K = 25

4.0     Evaluate complex function via vectors (Exercise 1A)

Consider the below system.

4.1  Define point  s and G(s) in MATLAB, where s  = −3 + j4.

4.2 Now evaluate magnitude M andangle θ for G(s) at points. Make sure to state the angle in degrees.

4.3   Repeat part 4.2 using manual techniques and verify the answers.

5.0     Root Locus analysis (Exercise 1B)

5.1       Sketch the root locus for the system that has the forward transfer function:

5.2       Consider unity feedback system that has the below forward transfer function:

a)   Define G(s) in MATLAB and sketch the Root Locus.

b)  Find the imaginary-axis crossings by clicking on the appropriate points on the plotted root locus and also the corresponding K (hint: check help rlocfind).

c)   Plot 0.45 damping ratio line and find where the Root Locus crosses. Also find the corresponding K (hint: check help sgrid).

d)  Find the range of gain, K, for which the system is stable.

e)  Now plot both 5.1 and 5.2(a) in the same diagram.

References

 Gene F. Franklin, J. Da Powell, Abbas Emami-Naeini, Feedback Control of Dynamic Systems, 7th Edition.

 Katsuhiko Ogata, Modern Control Engineering, 5th Edition.


发表评论

电子邮件地址不会被公开。 必填项已用*标注