3.7.1 MATLAB Representation of Linear Systems
The transfer function of the system is represented by two arrays. Consider the following system:
|
(3-17)
|
The system can be represented as two arrays, each consisting of the corresponding polynomial coefficients, arranged in descending powers of s as follows:
num = [0 0 25]
den = [1 4 25]
Note that zeros need to be added when necessary.
If num and den (i.e., the numerator and denominator of the closed-loop transfer function) are known, the commands step(num, den), step(num, den, t) will generate a unit step response graph (in the step command, t is the user-specified time).
When the left side of the step command contains variables, such as: [y,x,t]=step(num,den,t), the response curve will not be displayed on the screen. Therefore, the plot command must be used to view the response curve. The matrices y and x contain the output response and state response of the system at the calculation time point t respectively (the number of columns in y is the same as the number of output quantities, and each row corresponds to a corresponding time t unit. The number of columns in x is the same as the number of states, and each row corresponds to a corresponding time t unit).
3.7.2 Method for finding the unit step response of a transfer function system
The unit step response of the system described by equation (3-17) is discussed below. MATLAB Program3-1 will give the unit step response curve of the system. The unit step response curve is shown in Figure 3-13.
The source program is:
MATLAB Program 3-1
num=[0 0 25];
den=[1 4 25];
step(num,den)
grid
title('Unit-Step Response of G(s)=25/(s^2+4s+ 25)')
Figure 3-13 Unit step response curve
|
3.7.3 Writing text on the graphics screen
To write text on the graphics screen, for example, you can enter the following statements:
text(3.4, -0.06, 'Y1')
and
text(3.4, 1.4, 'Y2')
The first statement tells the computer to write "Y1" at the coordinate point x=3.4, y=-0.06. Similarly, the second statement tells the computer to write "Y1" at the coordinate point x=3.4, y=1.4.
3.7.4 Impulse Response
The unit impulse response of the control system can be obtained by using one of the following MATLAB commands:
impulse(num,den)
[y,x,t]=impulse(num,den)
[y,x,t]=impulse(num,den,t)
Example 3-11
Try to find the unit impulse response of the following system: . MATLAB Program3-2 will generate an impulse response. The resulting unit impulse response curve is shown in Figure 3-14.
The source program is:
MATLAB Program 3-2
num=[0 0 1];
den=[1 0.2 1];
impulse(num,den);
grid
title('Unit-Impulse Response of G(s)=1/(s^2+0.2s+1)')
Figure 3-14 Unit impulse response curve
|
3.7.5 Another method for finding the impulse response
When the initial condition is zero, the unit impulse response of G(s) is the same as the unit step response of sG(s).
Consider the unit impulse response of the system discussed in the previous example. Since R(s) = 1 for a unit impulse input,
Therefore, the unit impulse response of G(s) can be transformed into the unit step response of sG(s).
If we input the following num and den into MATLAB:
num=[0 1 0]
den=[1 0.2 1]
Using the step response command given in MATLAB Program3-2, the unit impulse response curve of the system can be obtained, as shown in Figure 3-15. In Figure 3-15, the x-axis and y-axis are automatically labeled. If you want to label the x-axis and y-axis differently, you need to change the step command. For example, if you need to label "t Sec" on the x-axis and "Input and Output" on the y-axis, you should use the step response command with the left-hand variable. The source program is as follows:
MATLAB Program 3-3
num=[0 1 1];
den=[1 0.2 1];
impulse(num,den);
grid;
title('Unit impulse response of G(s)=s/(s^2+0.2s+1)')
Figure 3-15
Unit impulse response curve obtained by using the unit step response of
|
c=step(num,den,t)
or
[y,x,t]=step(num,den,t)
see MATLAB Program3-4.
3.7.6 Ramp response
There is no ramp response command in MATLAB, so you need to use the step response command to find the ramp response. In particular, when finding the ramp response of the transfer function system G(s), you can first divide G(s) by s and then use the step response command. For example, consider the following closed-loop system:
For a unit ramp input, R(s)=1/(s2), so
In order to obtain the unit ramp response of the system, enter the following numerator and denominator into the MATLAB program:
num=[0 0 0 1];
den=[1 1 1 0];
and apply the step response command. See MATLAB Program3-4. The response curve obtained using this program is shown in Figure 3-16. The source program is as follows:
MATLAB Program 3-4
num=[0 0 0 1];
den=[1 1 1 0];
t=0:0.1:7;
c=step(num,den,t);
plot(t,c,'o ',t,t,'-')
grid;
title('Unit-Ramp Response Curve for System G(s)=1/(s^2+s+1)')
xlabel('t Sec')
ylabel(' Input and Output')
Figure 3-16 Unit ramp response curve
|
|