Solution 3.8.6.8
The rst step is to get the data into MATLAB. The followng commands do
that.
EDU>load tfid
EDU>size(tfid)
ans =
500 2
EDU>
the rst column is the time, and the second column is the step response.
Weusethe following commands to put the data in a form wecan plot the
step response versus time.
EDU>t = tfid(1:500,1);;
EDU>y = tfid(1:500,2);;
EDU>plot(t,y)
EDU>print -deps sr3868a.eps
EDU>
The time response is shown in Figure`1 As can be seen the time response,
whichwas taken o the oscilloscope shows negativetimebeforethe step is
applied and also the system does not start exactly at zero. The downward
trend just before t =0iswherethe switchwas thrown in the analog circuit
to initiate the step. So wehave some choices to make. We need to clean the
data up a bit to apply the identication technique described in this chapter.
First of all, we add 0.0399872 seconds to t and set t(77) = 0, and y(77) = 0.
Then we truncate the t and y vectors to the entries in locations 40 through
vehundred. The commands are:
t=t+0.04399872;;
t(77) = 0;;
y(77) = 0;;
t=t(77:500);;
y=y(77:500);;
plot(t,y);;
print -deps sr3868b.eps;;
1
-1 0 1 2 3 4 5
0
0.5
1
1.5
2
2.5
3
3.5
4
4.5
Figure 1: Rawstep response data
The adjusted response is shown in Figure 2. The rationale for the adjust-
ments are as follows. The response was generated bycreating a second order
comepensator on the Feedback and Control box(FAC). The system response
at steady state is almost exactly one in reponse to a 1 V input. Thus, all we
wanttodoisget zero to be the pointatwhich the switchonthe FACwas
thrown to initiate the step and the response goes down close to zero. This
turns out to be approximately t = ;0:24 s. Wearenowinaposition to
apply the identication techniques discussed in Chapter 3. As a rst step,
wecreate the function 1; y(t)asshown bytheMATLAB dialogue:
EDU>max(y)
ans =
4.0600000000000000
EDU>y1 = 4.06-y;;
EDU>w = log(y1);;
EDU>plot(t,w)
2
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5
0
0.5
1
1.5
2
2.5
3
3.5
4
4.5
Figure 2: Adjusted step response
EDU>
The result is shown in Figure 3. The slope is roughly
;
1:4+2:125
1:5
= ;2:35:
Wenowattempt to nd a good estimate of B.We generate B over a
range of values of t,andplot B,withthe MATLAB statements:
B=(y-4.06)./exp(-2.35*t);;
plot(t(50:250),B(50:250)
print -deps sr3868d.eps
Figure 4 shows a plot of B versus t for 0:5 <t<2:5seconds. Note that the
curveis
at for 0:5 <t<1:25, and \on average "
at for 1:25 <t<1:75.
We will use these tworegions to try to nd an estimate of B.Thereason
that we use both regions is simply that wemust have
jBj > jAj =4:06:
We nd our estimates of B using the MATLAB dialogue:
3
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
0.5
1
1.5
Figure 3: Adjusted step response
EDU>mean(B(50:75))
ans =
-3.64249102381882
EDU>mean(B(150:175))
ans =
-4.78636034776858
EDU>mean(B(125:175))
ans =
-4.41616801718234
EDU>plot(t(125:175),B(125:175))
4
EDU>print -deps Bb.eps
EDU>mean(B(115:150))
ans =
-3.87770352545026
EDU>mean(B(120:150))
ans =
-3.93368201732749
EDU>mean(B(125:140))
ans =
-4.08642988473146
EDU>mean(B(130:150))
ans =
-4.06638038526051
EDU>mean(B(135:150))
ans =
-4.13770851393740
EDU>plot(t(135:150),B(135:150))
EDU>mean(B(135:160))
ans =
-4.39212730667767
EDU>plot(t(135:160),B(135:160))
EDU>mean(B(135:170))
5
0 0.5 1 1.5 2 2.5
-30
-25
-20
-15
-10
-5
0
Figure 4: B for 0:5 <t<2:5seconds
ans =
-4.55674832530445
EDU>plot(t(135:170),B(135:170))
EDU>print -deps Bd.eps
EDU>plot(t(135:160),B(135:160))
EDU>print -deps Bc.eps
EDU>
This dialogue represents the searchforagoodestimate of B.Notethat our
initial estimates are too low(less than 4.06). In the process of looking for
B we also plot B versus time. What wearelooking for is a mean slope of
zero. Figure 4 is the global picture. Wesee that the plot of B B is very
at
out to t =1:5s,andrelatively
at again for 1:25 <t<1:75. Figures 5 is a
plot of B for 1:25 <t<1:75 s. Here the average slope is slightly downward.
Figure 6shows B for 1:35 <t<1:60 s, and Figure 7 B for 1:35 <t<170.
We see that the average slope is still relatively
at in FIgure 6, but tilted
6
1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9
-9
-8
-7
-6
-5
-4
-3
-2
-1
Figure 5: B for 0:125 <t<1:75 s
downward somewhat in Figure 7. Therefore, a reasonable guess is
B =4:4:
It maybealittle smaller, say4.1 or 4.2, but it probably isn't muchbigger.
This is, of course, educated guesswork, but educated nonetheless.
We next nd
y
1
(t) = A+Be
;4t
= 4:06;4:4e
;2:35t
;;
and compare it to the measured response, as shown in Figure 8. The t is
excellent. The t is prettygood.If weletp
1
=2:5wegettheplotinFigure 9
The t is muchbetter here. If weletP ;1=3weget the comparison shown
in Figure 10 Thus, p
1
=2:5looks likeaslightly better estimate. Wenow
denitely knowthat
2:35 <p
1
< 3:
We next form
y
2
(t) = y(t);y
1
(t)
= Ce
;p
2
t
;;
7
1.3 1.35 1.4 1.45 1.5 1.55 1.6 1.65
-6.5
-6
-5.5
-5
-4.5
-4
-3.5
-3
-2.5
Figure 6: B for 1:35 <t<1:6s
1.3 1.35 1.4 1.45 1.5 1.55 1.6 1.65 1.7 1.75
-9
-8
-7
-6
-5
-4
-3
-2
-1
Figure 7: B for 1:35 <t<1:7s
8
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5
-0.5
0
0.5
1
1.5
2
2.5
3
3.5
4
4.5
Figure 8: Measured reponse versus y
1
(t), p
1
=2:35
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5
-0.5
0
0.5
1
1.5
2
2.5
3
3.5
4
4.5
Figure 9: Measured reponse versus y
1
(t), p
1
=2:5
9
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5
-0.5
0
0.5
1
1.5
2
2.5
3
3.5
4
4.5
Figure 10: Measured reponse versus y
1
(t), p
1
=3
and then plot the natural logarithm of this function verus time as shown in
Figures 11 and 12.
From Figure 12 we see that the P
2
must be quite large, because the slope
very quickly becomes quite shallow, indicating that the eect of the pole at
s = ;p
2
is over very quickly.From Figure 11, wecantrytogetareasonable
estimate of p
2
.Wecompute three slopes:
;0:4;(;1:81)
0:07
= 20:4
;0:4; (;1:8)
0:08
= 17:5
;0:4;(;1:72)
0:106
= 12:45
Wecannowsaywith some condence that
12 <P
2
< 20:
10
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
Figure 11: Plot of ln[y
2
(t)], 0 <t;;0:75 s
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4
-2.6
-2.4
-2.2
-2
-1.8
-1.6
-1.4
-1.2
-1
-0.8
Figure 12: Plot of ln[y
2
(t)], 0 <t;;1:25 s
11
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5
-0.5
0
0.5
1
1.5
2
2.5
3
3.5
4
4.5
Figure 13: Measured versus estimated step reponse
We know that
C = ;(A+ B)=;(4:06;4:4) = 0:34:
If wechose p
2
= ;17:5, then our estimate of y(t)is
^y(t)=4:06; 4:4e
;2:5t
+0:34e
;17:5t
:
This estimate is compared to the measured response in Figure 13.
The last task is to estimate
K
p
1
p
2
=4:06;;
or
K =4:062:517:5=177:6
The transfer function is then
G(s)=
177:6
(s+2:5)(s+17:5)
:
12