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

PETUNJUK PRAKTIKUM SISTEM INSTRUMENTASI KENDALI

INTRODUCTION TO MATLAB FOR CONTROL SYSTEM DESIGN

Dosen pengampu

Sutanto

PROGRAM STUDI ELEKTRONIKA INSTRUMENTASI


JURUSAN TEKNOFISIKA NUKLIR
SEKOLAH TINGGI TEKNOLOGI NUKLIR
BADAN TENAGA NUKLIR NASIONAL
2018
I. THEORY
A. MATLAB
MATLAB (Matrix Laboratory) is an interactive program for scientific and engineering calculations.
MATLAB can be used for control system design and analysis. There are 4 objects that we use to interact
with the program:
1. Statements and variables
2. Matrices
3. Graphics
4. Scripts

1. Statements and Variables


Form of MATLAB statement is shown in Fig. 1. A value is expressed by a variable. Since MATLAB is
case sensitive, the variables “M” and “m” are not the same variables. The usual mathematical operators
are shown in Table 1. MATLAB has several predefined variables, including pi, Inf, Nan, i, and j. Nan
means Not-a-Number and results from undefined operations. i and j are for representing complex
numbers.

Fig. 1 MATLAB statement form

Table 1 Mathematical operators

2. Matrices
Input of a matrix can be carried out as below:

The important basic matrix operations are addition and subtraction, multiplication, transpose,
powers, and so-called array operations, which are element-to-element operations. Colon notation
allows us to generate a row vector containing the numbers from a given starting value, xi, to a final
value, xf, with a specified increment, dx. It is shown in Fig. 2.

Fig. 2 The colon notatios


We can easily generate vectors using the colon notation. This is quite useful for developing x-y plots.
Suppose our objective is to generate a plot of y = x sin(x) versus x for x = 0, 0.1, 0.2, …, 1.0. Our first step
is to generate a table of x-y data. We can generate a vector containing the values of x at which the
values of y(x) are desired using the colon notation. This is illustrated in Fig. 3.

Fig. 3 Generating vectors using the colon notation


3. Graphics
Graphics play an important role in both the design and analysis of control systems. There are two
basic groups of graphics functions. The first group specifies the type of plot as shown in Table 2. The
second group allows us to customize the plots, as shown in Table 3, by adding titles, axis labels, and text
to the plots, and to change the scales and display multiple plots in subwindows.

Table 2 Available plot formats

Table 3 Function of customized plots

Example of drawing graphics are shown in Figs. 4 and 5.


Fig. 4 Plot with single line

Fig. 5 Plot with multiple lines


4. Script
Script is one type of M-files where we write a long sequence of commands. The real power of
MATLAB for control system design and analysis derives from its ability to execute a long sequence of
commands stored in a file (M-file). Suppose we want to plot the function y(t) = sin αt, where α is a
variable that we want to vary. Using our favorite text editor, we write a script, which we will call
plotdata.m. We can give input α through command window and execute the script by typing in plotdata
at the command window. The script plotdata.m will use the most recent value of α. The script is shown
in Fig. 6

Fig. 6 A simple script to plot the function y(t) = sinαt

Output of executing the script is shown in Fig. 7.

Fig. 7 Output of executing the example of script


B. MATHEMATICAL MODELING OF SYSTEMS
The design and analysis of control systems is based on mathematical model of complex physical
systems. The mathematical models, which follow from the physical laws of the process, are generally
highly coupled nonlinear differential equations. Fortunately, many physical systems behave linearly
around an operating point within some range of the variables, and it is possible to develop linear
approximations to the physical systems.

MATLAB can be used to assist in the analysis of a typical system, for example a spring-mass-
damper. Using a MATLAB, we will develop an interactive analysis capability to analyze the effects of
natural frequency and damping on the unforced response of the mass displacement. In particular, we
are interested in how MATLAB can assist us in manipulating polynomials, computing poles and zeros of
transfer functions, computing closed-loop transfer functions, block diagram reduction, and computing
the response of a system to a unit step input.

1. Spring-Mass-Damper System
A spring-mass-damper mechanical system is shown in Fig. 8

Fig. 8 Spring-mass-damper system

The motion of the mass, denoted by y(t), is described by the differential equation.

r(t) represents the forcing function. The model is based on lumped, linear time-invariant approximation
to the physical process. It is valid only in regions where the spring force is a linear function of the mass
displacement, and the damping due to friction is a linear function of the velocity.

The mathematical model might represent an off-road vehicle shock absorber. Our objective
could be to design an active control system to make the ride smoother when traversing unpaved roads.
The control design and subsequent analysis would be based on the vehicle shock absorber model in the
Eq. The real test of the control design is to meet the objective of smoother ride on a bumpy road, but
we will see how to use MATLAB to enhance our control design and analysis capability.
The unforced dynamic response, y(t), of the spring-mass-damper mechanical system is

Where ϴ = cos-1ζ. The initial displacement is y(0). The transient system response is underdamped when ζ
<1, overdamped when ζ > 1, and critically damped when ζ = 1. Consider the overdamped and
underdamped cases:

• Case 1: y(0)=0.15m, ωn=21/2 rad/s, ζ1 = 3/(2x21/2), (K/M=2, f/M=3)


• Case 2: y(0)=0.15m, ωn=21/2 rad/s, ζ1 = 1/(2x21/2), (K/M=2, f/M=1)

The MATLAB commands and script to generate the plot of the unforced response are shown in Fig.
9. In the MATLAB setup, the variables y(0), ωn, t, ζ1, and ζ2 are input typed in the MATLAB command
window. The time-response plot is in Fig. 10. Since you can relate the natural frequency and damping
ratio to the spring constant, K, and friction f, you can also analyze the effect of K and f on the response.

Fig. 9 Script to analyze the spring-mass-damper


Fig. 10 Spring-mass-damper unforced response

2. Transfer Function
The transfer function is an input-output description of an LTI system. It relates the Laplace transform
of the output variable to the Laplace transform of the input variable with zero initial conditions.
Consider the LTI system described by the transfer function G(s), where

Where m<=n. The roots of the numerator polynomial of G(s) are called the zeros of the system; the
roors of the denominator polynomial are called the poles. Setting the denominator polynomial to zero
yields the characteristic equation

The transient response of a system is directly related to the s-plane locations of the poles and zeros.
Example of how to find roots of characteristics eq. is shown below:

Multiplication of polynomials is accomplished with the conv function. Suppose we want to expand the
polynomial n(s), where
The associated MATLAB commands using the conv function are as below:

Consider the transfer functions:

Using MATLAB, we can plot the location of the pole-zero using command as below:

We can also plot the pole-zero for the transfer function of G(s)/H(s) by using script as below:
The result is shown below

II. ASSIGNMENT

A. Introduction to MATLAB

1. Matrices Generation
Generate matrices A, B, and C with size of 1 x 2, 2 x 2, 2 x 3, by using MATLAB. The values of the
matrices are up to you. Write down the commands and the execution results for your short
discussion.
2. Plot a curve of function y = x.sin(x) with range of x values from 0 to 1.0. Plot also a curve of y = sin(x).
Plot these function in single figure.
3. Given data in excel (provided by teacher), plot the data by using MATLAB with script as below:
data=xlsread('Data_prakt.xlsx');
x=data(:,1);
y1=data(:,2);
y2=data(:,3);
y3=data(:,4);
% PLOT KETERANGAN AKSIS
yyaxis left
%title('Plots with Different y-Scales')
xlabel('Time (s)')
ylabel('Power to flow ratio')
yyaxis right
ylabel('Steam temperature (^oC)')
% PLOT DATA
hold on
yyaxis left
plot(x,y1);
plot(x,y2);
yyaxis right
plot(x,y3);
hold off

B. System Modeling
1. Spring-mass-damper unforced response
Based on Fig. 8 and its model, shown the system’s response by typing the following script.
Execute and observed the results for discussion in your report.
2. Pole-Zero
Given transfer functions as below:

Plot the pole-zero location of the transfer function G(s)/H(s) by typing the script below:

Using the same way, plot the pole-zero location for the transfer function of each G(s) and H(s).

Вам также может понравиться