You are on page 1of 58

Solutions to Problems in Chapter Eight

Solutions to Test Your Understanding Problems


T8.1-1
_

0
sin xdx = cos x|

0
= cos + cos 0 = 1 + 1 = 2
T8.1-2 The equation of motion is m v = f, or v = f/m = 5g.
(a)
v(10) =
_
10
0
5g dt = 5g(10) = 50(9.81) = 490.5 m/sec
(b)
v(t) =
_
t
0
5g dt = 5gt
h(t) =
_
10
0
v(t) dt =
_
10
0
5gt dt = 5g
t
2
2

10
0
= 250g = 2452.5 meters
T8.1-3
(a) Let y = 3x. Then
d sin 3x
dx
=
d sin y
dy
dy
dx
= (cos y)3 = 3 cos 3x
(b) Let y = cos x. Then
d cos
2
x
dx
=
dy
2
dy
dy
dx
= 2y(sin x) = 2 cos x sin x
(c)
dx
3
ln x
dx
=
dx
3
dx
ln x + x
3
d ln x
dx
= 3x
2
ln x +
x
3
x
= x
2
(3 ln x + 1)
(d) Let f = sin x and g = x
2
. Note that
d(f/g)
dx
=
g
df
dx
f
dg
dx
g
2
Then
d (sin x)/x
2
dx
=
x
2
cos x 2x sin x
x
4
=
x cos x 2 sin x
x
3
T8.2-1 Use the velocity calculations given in the table in Example 8.2-1. The script le is
similar to the third script le in Example 8.2-1, with v replacing a and x replacing v.
8-1
t = [0:10];
v = [0,1,4,9.5,18.5,32.5,53,81,117,162,211.5];
x(1) = 0;
for k = [1:10]
x(k+1) = trapz(t(k:k+1),v(k:k+1))+x(k);
end
disp([t

,x

])
The results are (time is in the rst column; displacement is in the second column):
0 0
1.0000 0.5000
2.0000 3.0000
3.0000 9.7500
4.0000 23.7500
5.0000 49.2500
6.0000 92.0000
7.0000 159.0000
8.0000 258.0000
9.0000 397.5000
10.0000 584.2500
T8.2-2 The closed form solution is
_
5
2
1
x
dx = ln x|
5
2
= ln 5 ln 2 = ln
5
2
= 0.9163
The Matlab session is as follows.
quad(

1./x

,2,5)
ans =
0.9163
quadl(

fn

,2,5)
ans =
0.9163
Here quad and quadl give the same result to four decimal places.
T8.2-3 The session is
quad(

sqrt

,0,1,.001)
ans =
0.6635
8-2
quadl(

sqrt

,0,1,.001)
ans =
0.6666
The value obtained with quad and quadl using the default tolerance is 0.6667 to four decimal
places. Thus a tolerance of 0.001 produces a less accurate answer.
T8.3-1 The forward dierence estimate is simply shifted one index relative to the backward
dierence estimate. Thus, simply replace the rst plot command in the program given in
the text above the problem with plot(x(2:n),td(2:n),x(1:n-1),d1,o),xlabel(x),...,
and change the gtext labeling function. The results are shown in the gure. As you would
expect, the backward estimate performs similarly to the forward estimate.
0 0.5 1 1.5 2 2.5 3
2
1
0
1
2
x
D
e
r
i
v
a
t
i
v
e
Forward Difference Estimate
0 0.5 1 1.5 2 2.5 3
2
1
0
1
2
x
D
e
r
i
v
a
t
i
v
e
Central Difference Estimate
Figure : for Problem T8.3-1.
T8.4-1
(a) The roots are s = 4 and 7. The form of the free response is
y(t) = C
1
e
4t
+ C
2
e
7t
(b) The roots are s = 3 5i. The form of the free response is
y(t) = Be
3t
sin(5t + )
8-3
(c) The roots are s = 3 and 5. The form of the free response is
y(t) = C
1
e
3t
+ C
2
e
5t
(d) The roots are s = 4 and 10. The form of the free response is
y(t) = C
1
e
4t
+ C
2
e
10t
T8.5-1 Solve for the derivative:
dy
dt
=
te
2t
y
10
The models time constant is 10, but the time constant of the input is 0.5. So we select
to be a small fraction of 0.5, say = 0.5/20. The script le for the Euler method is
delta = .5/20;
y(1)=2;
k = 0;
for time = [delta:delta:2]
k = k+1;
y(k+1) = y(k) + 0.1*(time*exp(-2*time)-y(k))*delta;
end
t = [0:delta:2];
y_true = (732*exp(-0.1*t)-19*t.*exp(-2*t)-10*exp(-2*t))/361;
plot(t,y,o,t,y_true),xlabel(t),ylabel(y)
The plot is shown in the gure. The numerical solution is shown by the circles. It matches
the true solution.
The script le for the modied Euler method is shown in the gure. Its plot is similar
to that of the Euler method.
delta = .5/20;
y(1)=2;
k = 0;
for time = [delta:delta:2]
k = k+1;
x(k+1) = y(k) + 0.1*(time*exp(-2*time)-y(k))*delta;
y(k+1) = y(k)+(delta/2)*(0.1*(time*exp(-2*time)-y(k)) + ...
0.1*(time*exp(-2*time)-x(k+1)));
end
t = [0:delta:2];
y_true = (732*exp(-0.1*t)-19*t.*exp(-2*t)-10*exp(-2*t))/361;
plot(t,y,o,t,y_true),xlabel(t),ylabel(y)
8-4
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
1.65
1.7
1.75
1.8
1.85
1.9
1.95
2
t
y
Figure : for Problem T8.5-1a.
T8.5-2 Dene the function le:
function ydot = T8P5D2(t,y)
global tau, a, b, c, y0
v = a + b*sin(c*t);
ydot = (v-y)/tau;
The script le for = 3, a = 5, b = 2, c = 8, y(0) = 6, and 0 t 10 is
global tau, a, b, c, y0
tau = 3;a = 5;b = 2;c = 8;y0 = 6;tf = 10;
[t,y] = ode23(

T8P5D2

, [0, tf], y0);


plot(t,y),xlabel(

),ylabel(

)
T8.6-1 First create the function le msd shown in the text. Then create the following script
le, which calls msd.
global c f k m
8-5
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
3
2
1
0
1
2
3
4
5
6
Time (sec)
D
i
s
p
l
a
c
e
m
e
n
t

(
m
)

a
n
d

V
e
l
o
c
i
t
y

(
m
/
s
e
c
)
Velocity
Displacement
Figure : for Problem T8.6-1.
m = 2;c = 3;k = 7;f = 35;
[t,x]=ode23(msd, [0, 5], [2,-3]);
plot(t,x),xlabel(Time (sec)),...
ylabel(Displacement (m) and Velocity (m/sec)),...
gtext(Velocity),gtext(Displacement)
The plot is shown in the gure.
8-6
T8.7-1
sys1 = tf(1,[5,7,4]);
[A,B,C,D] = ssdata(sys1);
sys2 = ss(A,B,C,D);
sys3 = tf(sys2)
[right, left] = tfdata(sys3, v)
right = 1
left = 5.000 7.000 4.000
Thus we obtain the same equation coecients that we started with.
Solutions to End-of-Chapter Problems
1. The analytical solution is easier. It is
x(10) =
_
10
2
(5 + 7t
2
) dt =
_
5t +
7t
3
3
_

10
2
= 40 +
6944
3
= 2354.6667
The Matlab session is
x = quad(

2.3547e+003

,2,10)
x =
2.3547e+003
2. The analytical solution is easier. The total distance traveled is
D(1) =
_
1
0
|cos t| dt =
_
1/2
0
cos t dt +
_
1
1/2
cos t dt
or
D(1) = 2
_
1/2
0
cos t dt = 2
sinpit

1/2
0
=
2

_
sin

2
sin 0
_
=
2

The displacement is
x(1) =
_
1
0
v(t) dt + x(0) =
_
1
0
cos t dt + 2 =
sin t

2
0
+ 2 = 2
The Matlab session is
D = quad(

abs(cos(pi*x))

,0,1)
D =
0.6366
x = quad(

cos(pi*x)

,0,1)+2
x =
2
8-7
3. We must integrate twice to nd the distance, and this is dicult to do in Matlab with
the numerical integration functions quad and trapz. Thus the analytical solution is easier.
It is
v(t) =
_
t
0
a(t) dt + v(0) =
_
t
0
5t dt + 3 =
5t
2
2

t
0
+ 3 =
5t
2
2
+ 3
The plot is shown in the gure.
To nd the distance D traveled in 5 seconds, note that the velocity is always positive.
Thus
D =
_
5
0
_
5t
2
2
+ 3
_
dt =
_
5
2
t
3
3
+ 3t
_

t=5
= 119.1667 meters
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
0
10
20
30
40
50
60
70
Time (sec)
V
e
l
o
c
i
t
y

(
m
/
s
e
c
)
Figure : for Problem 8.3.
4. Analytical solution:
v(t) =
1
C
_
t
0
i dt = 10
5
_
t
0
2(1 + sin 5t)10
4
dt = 20
_
t
0
(1 + sin 5t) dt
or
v(t) = 20t + 20
cos 5t
5

t
0
= 20t 4 cos 5t + 4
The plot is shown in the gure.
8-8
Because a plot was requested, it is easier to do this problem analytically. However, for
functions that are dicult to evaluate analytically, a numerical solution can be obtained by
using the quad function repetitively. This method is based on the fact that we can write
the integral as the sum of integrals. See the solution to Problem 14 for a discussion of this
method.
0 0.2 0.4 0.6 0.8 1 1.2
0
5
10
15
20
25
t
v
Figure : for Problem 8.4.
8-9
5. The analytical solution is easier. It is
W =
_
5
1
k
x
dx = kx
1

5
1
= 0.8k
To solve the problem with Matlab, rst dene the following function. The session is
I = quad(

1./x.^2

,1,5)
I =
0.8000
Thus W = kI = 0.8k.
6. The analytical method is the easiest because the derivatives of x(t) are easily found.
v(t) =
dx
dt
= 6 sin 5t + 30t cos 5t
a(t) = 30 cos 5t + 30 cos 5t 150t sin 5t = 60 cos 5t 150t sin 5t
The script le to plot these functions is given below. We use a time increment that is a
small fraction of the period, which is 2/5.
dt = (1/50)*(2*pi/5);
t = [0:dt:5];
v=6*sin(5*t)+30*t.*cos(5*t);
a=60*cos(5*t) -150*t.*sin(5*t);
plot(t,v,t,a),xlabel(t),ylabel(Velocity and Acceleration),...
gtext(v),gtext(a)
The plot is shown in the gure.
7. The problem should be done analytically. The solution is
v =
dh
dt
= 6 2(4.9)t
Thus
v(0) = 6
The answer is in meters/second.
8. The problem must be done analytically. The solutions are:
(a)
dV
dh
= 2rh h
2
8-10
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
800
600
400
200
0
200
400
600
800
t
V
e
l
o
c
i
t
y

a
n
d

A
c
c
e
l
e
r
a
t
i
o
n
v
a
Figure : for Problem 8.6.
(b)
dV
dt
=
dV
dh
dh
dt
= (2rh h
2
)
dh
dt
9. The problem must be done using numerical integration because the velocity is not given
as a function.
x(10) =
_
10
0
v(t) dt + x(0) =
_
10
0
v(t) dt + 3
The script le is
v = [0,2,5,7,9,12,15,18,22,20,17];
x = trapz(v) + 3
Note that trapz does not require a vector of time values because the spacing between the
time values is 1. The answer is x(10) = 121.5 meters.
10. This problem is much easier to do numerically. The relation between height h and the
volume inow rate r is
100
dh
dt
= r
8-11
Thus
h(t) =
1
100
_
t
0
r dt
The Matlab m-le is
t = [0:10];
r = [0,80,130,150,150,160,165,170,160,140,120];
h = (1/100)*trapz(t,r)
The answer for the nal height is given by h and is 13.65 feet.
11. This problem requires both analytical and numerical methods.
(a) Let
b =
1
3

_
R
H
_
2
=
1
3

_
1.5
4
_
2
=
3
64
Then V = bh
3
. When the cup is full, h = 4 inches, and the water volume is V = b(4)
3
=
64b = 3.
Let q be the ow rate (q = 2 cubic inches per second). From mass conservation,
dV
dt
= q
and
V (t) =
_
t
0
q(t) dt =
_
t
0
2 dt = 2t
Equating the two expressions for the water volume gives 2t = 64b, or t = 32b = 3/2 = 4.7
seconds.
(b) If q(t) = 2(1 e
2t
), then
V (t) =
_
t
0
q(t) dt =
_
t
0
2(1 e
2t
) dt =
_
2t
2e
2t
2
_

t
0
= 2t + e
2t
1
The time to ll is found by equating the two expressions for the volume:
2t + e
2t
1 = 64b = 3
We can solve this for t either by plotting the expression or by using the fzero function.
First dene the function cup:
function f = cup(t)
f = 2*t+exp(-2*t)-1 - 3*pi;
Use the fzero function with the answer from part (a) as the starting guess:
8-12
fzero(cup,4.7)
ans =
5.2124
Thus it will take about 5.2 seconds to ll the cup.
12. From Newtons law m v = f, or
v =
500
100
_
2 e
t
sin(5t)
_
Integrate from t = 0 to t = 5, using v(0) = 0:
v(5) = 5
_
5
0
_
2 e
t
sin(5t)
_
dt
Because a plot of v(t) is not asked for, it is easier to do this problem numerically, even
though the integral can be found in most tables (its expression is a little messy). Use the
quadl function as follows (the quad function warned of a singularity in this problem and
gives a slightly dierent answer, so we use the quadl function):
5*quadl(2-exp(-t).*sin(5*pi*t,0,5)
ans =
49.6808
Thus the velocity is 49.6808 meters/second after 5 seconds.
13. Note that m(t) = 2200(1 0.8t/40) and that
dv
dt
=
T
m(t)
g
Integrate both sides of this equation to obtain
v(40) =
_
40
0
T
m(t)
dt 40g =
_
40
0
48000
2200(1 0.8t/40)
dt 40g
or
v(40) =
_
40
0
240
11(1 0.02t)
dt 40(9.81)
The analytical solution is
v(40) =
240
0.02(11)
ln (1 0.02t)|
40
0
40(9.81) = 1363.4
Thus the burnout velocity is 1363.4 meters/second.
The Matlab session is
8-13
quad(240./(11*(1-.02*t)),0,40)-40*9.81
ans =
1.3634e+003
The velocity at burnout is 1363.4 meters/second.
14. The integral is
v(t) =
1
10
6
_
t
0
_
0.01 + 0.3e
5t
sin(25t)
_
10
3
dt =
_
t
0
_
10 + 300e
5t
sin(25t)
_
dt
Both the analytical and numerical solution methods have the pros and cons with this prob-
lem. The integral is messy to evaluate analytically, but we need to plot the voltage v(t),
which is harder to do with a numerical solution. Here is the analytical solution.
v(t) =
_
t
0
_
10 + 300e
5t
sin(25t)
_
dt = 10t + 300
_
e
5t
(5 sin 25t 25 cos 25t)
5
2
+ (25)
2
_

t
0
or
v(t) = 10t 0.0484e
5t
(5 sin 25t + 25 cos 25t) + 3.804
This function can now be plotted.
Here is the numerical solution. First dene the following function.
function f = fn(t)
f=10+300*exp(-5*t).*sin(25*pi*t);
The following script le solves for and plots the solution v(t) for 0 t 0.3. It uses the
fact that an integral can be expressed as the sum of integrals:
_
tn
0
f(t) dt =
_
t
1
0
f(t) dt +
_
t
2
t
1
f(t) dt + +
_
tn
t
n1
f(t) dt
tmin = 0;tmax = 0.3;n = 300;
t = linspace(tmin,tmax,n);
vp = 0;
for k = 1:n-1
v(k) = vp+quadl(fn,t(k),t(k+1));
vp = v(k);
end
plot(t(1:n-1),v),xlabel(t (sec)),ylabel(v (volts))
8-14
The plot is shown in the gure.
We note here that this problem can also be solved by converting the integral equation
into a dierential equation by dierentiating both sides with respect to t. The result is
dv
dt
= 10 + 300e
5t
sin(25t)
This equation can then be solved numerically with the dierential equation methods pre-
sented in Section 8.5.
0 0.05 0.1 0.15 0.2 0.25 0.3
0
1
2
3
4
5
6
7
8
t (sec)
v

(
v
o
l
t
s
)
Figure : for Problem 8.14.
8-15
15. The script le is a modication of that shown in Section 8.3.
x = [0:10];
y = [0,2,5,7,9,12,15,18,22,20,17];
n=length(x);
d1 = diff(y)./diff(x);
subplot(3,1,1)
plot(x(1:n-1),d1,x(1:n-1),d1,o),xlabel(x),...
ylabel(Derivative),axis([0 10 -5 5]),...
gtext(Forward Difference Estimate)
subplot(3,1,2)
plot(x(2:n),d1,x(2:n),d1,o),xlabel(x),...
ylabel(Derivative),axis([0 10 -5 5]),...
gtext(Backward Difference Estimate)
d2 = (y(3:n)-y(1:n-2))./(x(3:n)-x(1:n-2));
subplot(3,1,3)
plot(x(2:n-1),d2,x(2:n-1),d2,o),xlabel(x),...
ylabel(Derivative),axis([0 10 -5 5]),...
gtext(Central Difference Estimate)
The plot is shown in the gure. The three estimates agree where y is not rapidly chang-
ing. However, at the values of x where y is rapidly changing, the central dierence
methodsmoothes the data. Its estimate of the derivative does not uctuate as much
as the other estimates.
8-16
0 1 2 3 4 5 6 7 8 9 10
5
0
5
x
D
e
r
i
v
a
t
i
v
e
Forward Difference Estimate
0 1 2 3 4 5 6 7 8 9 10
5
0
5
x
D
e
r
i
v
a
t
i
v
e
Backward Difference Estimate
0 1 2 3 4 5 6 7 8 9 10
5
0
5
x
D
e
r
i
v
a
t
i
v
e
Central Difference Estimate
Figure : for Problem 8.15.
16. The data shows that a relative maximum is near x = 5 and that another maximum is
on the boundary at x = 10. One way to solve the problem is to t a polynomial to the data
near x = 5, and then dierentiate the polynomial. The script le is
x=[3:7];
y = [7,9,10,8,7];
p = polyfit(x,y,4);
xp=[3:.05:7];
yp = polyval(p,xp);
plot(x,y,o,xp,yp),xlabel(x),ylabel(y)
der = polyder(p);
solution = roots(der)
solution =
6.7366
4.8127
2.9508
The plot of the polynomial and the data shown in the gure conrms that there is a good
t.
8-17
3 3.5 4 4.5 5 5.5 6 6.5 7
6.5
7
7.5
8
8.5
9
9.5
10
10.5
x
y
Figure : for Problem 8.16c.
The polynomial has a zero derivative at x = 6.7366, 4.8127, and 2.9508. The solution
we want is x = 4.8127. The other two solutions correspond to minima of the polynomial.
The estimated maximum value of y is computed from the polynomial at x = 4.8127.
polyval(p,4.8127)
ans =
10.0627
Thus the estimated maximum value of y is 10.0627.
8-18
17. The true derivative is
dy
dx
= e
x
sin(3x) + 3e
x
cos(3x)
The script le is a modication of that shown in Section 8.3.
x = linspace(0,4,101);
n = length(x);
td = -exp(-x).*sin(3*x) +3*exp(-x).*cos(3*x);
y = exp(-x).*sin(3*x)+0.01*(rand(1,n)-0.5);
d1 = diff(y)./diff(x);
subplot(3,1,1)
plot(x(2:n),td(2:n),x(1:n-1),d1,o),xlabel(x),...
ylabel(Derivative),axis([0 4 -2 2]),...
gtext(Forward Difference Estimate)
subplot(3,1,2)
plot(x(1:n-1),td(1:n-1),x(1:n-1),d1,o),xlabel(x),...
ylabel(Derivative),axis([0 4 -2 2]),...
gtext(Backward Difference Estimate)
d2 = (y(3:n)-y(1:n-2))./(x(3:n)-x(1:n-2));
subplot(3,1,3)
plot(x(2:n-1),td(2:n-1),x(2:n-1),d2,o),xlabel(x),...
ylabel(Derivative),axis([0 4 -2 2]),...
gtext(Central Difference Estimate)
The plots are shown in the gure. The central dierence method gives the better estimate
of the derivative.
8-19
0 0.5 1 1.5 2 2.5 3 3.5 4
2
0
2
x
D
e
r
i
v
a
t
i
v
e
Forward Difference Estimate
0 0.5 1 1.5 2 2.5 3 3.5 4
2
0
2
x
D
e
r
i
v
a
t
i
v
e
Backward Difference Estimate
0 0.5 1 1.5 2 2.5 3 3.5 4
2
0
2
x
D
e
r
i
v
a
t
i
v
e
Central Difference Estimate
Figure : for Problem 8.17.
8-20
18. The analytical method is the easiest here because the analytical solution is given by
equation (8.4-10).
y(t) = 5e
t/5
+ 10
_
1 e
t/5
_
The response is at steady state after approximately t = 20. The following script le produces
the plot.
t = [0:.005:20];
y = 5*exp(-t/5)+10*(1-exp(-t/5));
plot(t,y),xlabel(t),ylabel(y)
0 2 4 6 8 10 12 14 16 18 20
5
5.5
6
6.5
7
7.5
8
8.5
9
9.5
10
t
y
Figure : for Problem 8.18.
8-21
19. The analytical method is the easiest here because the analytical solution is given by
equation (8.4-10).
y(t) = 2e
5t
+ 10
_
1 e
5t
_
The response is at steady state after approximately t = 4/5. The following script le
produces the plot.
t = [0:.003:4/5];
y = 2*exp(-5*t)+10*(1-exp(-5*t));
plot(t,y),xlabel(t),ylabel(y)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8
2
3
4
5
6
7
8
9
10
t
y
Figure : for Problem 8.19.
20. For t 0, the equation is
10
dT
dt
+ T = 170
with the initial condition T(0) = 70. The analytical solution is given by equation (8.4-10).
T(t) = 70e
t/10
+ 170
_
1 e
t/10
_
(a) The mathematical solution indicates that it will take an innite amount of time for
the objects temperature to reach the bath temperature.
8-22
(b) The initial temperature dierence is 170

70

= 100

. The time constant is 10


seconds, so it will take 40 seconds for the temperature dierence to decay to 2

, which is
2% of its initial value. Thus the objects temperature will be 168

at t = 40 seconds.
(c) The following script le produces the plot.
t = [0:.01:40];
T = 70*exp(-t/10)+170*(1-exp(-t/10));
plot(t,T),xlabel(t (seconds)),ylabel(T (degrees F))
0 5 10 15 20 25 30 35 40
70
80
90
100
110
120
130
140
150
160
170
t (seconds)
T

(
d
e
g
r
e
e
s

F
)
Figure : for Problem 8.20.
21. The analytical method is the easiest here because the analytical solution is given by
equation (8.4-10), which is based on equation (8.4-8). Put the sleds equation into the same
form as (8.4-8):
1000
500
v + v =
f
500
(a) If f is constant, the solution is given by (8.4-10) with v(0) = 0.
v(t) =
f
500
_
1 e
500t/1000
_
=
f
500
_
1 e
t/2
_
8-23
(b) As t , the solution shows that v f/500. The time constant is 2 seconds, and
the response is at steady state after approximately four time constants, or 8 seconds.
22. Because we are not given the initial conditions, we cannot use a numerical method
here. The form of the free response depends on the characteristic roots, which are the roots
of the following polynomial.
ms
2
+ cs + k = 0
(a) The characteristic polynomial is 3s
2
+18s+102 = 0, which has the roots: s = 35i.
Thus the form of the free response is
y(t) = Be
3t
sin(5t + )
where B and depend on the initial conditions. The free response oscillates with a frequency
of 5 radians/unit time. The time constant is found from the negative reciprocal of the real
part: = 1/3. The oscillations disappear after approximately four time constants, or
t = 4 = 4(1/3) = 4/3.
(b) The characteristic polynomial is 3s
2
+ 39s + 120 = 0, which has the roots: s = 5,
s = 8. Thus the form of the free response is
y(t) = A
1
e
5t
+ A
2
e
8t
where A
1
and A
2
depend on the initial conditions. The free response does not oscillate. The
dominant time constant is 1/5, and thus the free response decays to 0 after approximately
t = 4(1/5) = 4/5.
23. It is much easier to solve this problem numerically, especially because a plot is required.
With the given values, the model is
0.2
dy
dt
+ y = v(t)
Solve for dy/dt:
dy
dt
= 5[v(t) y]
where y(0) = 2 and v(t) = 10[2e
t
sin(5t)]. To use the ode23 solver, create the following
function le:
function ydot = rccirc1(t,y)
v = 10*(2-exp(-t)*sin(5*pi*t));
ydot = 5*(v-y);
Then use the ode23 solver in the following script le.
[t, y] = ode23(rccirc1, [0, 5], 2);
plot(t,y),xlabel(t (seconds)),ylabel( y (volts))
8-24
The plot is shown in the gure. The time constant of the inputs oscillations is 1 second, so
the oscillations should disappear after approximately 4 seconds. The period of the inputs
oscillations should be 2/5 second. The plot conrms these predictions. The circuits time
constant is 0.2 seconds. Thus if the applied voltage were constant, the steady-state would
be reached in about 4(0.2) = 0.8 seconds. This can be seen from the plot, which shows that
the response oscillates about a curve that levels o at y = 20 after about 0.8 seconds.
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
2
4
6
8
10
12
14
16
18
20
22
t (seconds)

y

(
v
o
l
t
s
)
Figure : for Problem 8.23.
8-25
24. For the given values
C
d
A = 0.5(2 10
2
)
2
= 2 10
4
and the dierential equation is
(6h h
2
)
dh
dt
= 2 10
4

19.62h
or
dh
dt
=
2 10
4

19.62h
6h h
2
(a) The greatest outow rate occurs when the water level is the highest (h = 5). Thus using
h = 5 in the dierential equation, we can obtain an lower bound on the time required to
drain the tank. When h = 5,
dh
dt
=
2 10
4

19.62h
6h h
2
= 3.9618 10
4
This implies that h(t) = 3.9618 10
4
t +5, and h = 0 at t = 5/(3.9618 10
4
) = 12, 620
seconds, or 210 minutes. Thus the tank will empty in no less than 210.34 minutes.
Instead of a lower bound on the estimate, we can obtain a higher estimate by using the
mid-point value for h; namely, h = 5/2 = 2.5. Thus gives
dh
dt
=
2 10
4

19.62h
6h h
2
= 1.6008 10
4
This implies that h(t) = 1.6008 10
4
t +5, and h = 0 at t = 5/(1.6008 10
4
) = 31, 234
seconds, or 521 minutes.
(b) To use the ode45 solver, solve for the derivative:
dh
dt
=
2 10
4

19.62h
6h h
2
and create the following function le:
function hdot = tank(t,h)
hdot = -(0.0002*sqrt(19.62*h))/(6*h-h^2);
Then use the ode45 solver in the following script le.
[t, h] = ode45(tank, [0, 25200], 5);
plot(t,h),xlabel(t (seconds)),ylabel( h (feet))
8-26
Start with a nal time of something more than 12,620 seconds, and run the le until the
plot shows the height approaching zero. The time to empty, which is 25,200 seconds or 420
minutes, was found this way. The estimate of 521 minutes obtained with the mid-point
height is not much dierent, and establishes condence in the numerical result.
Note that if you choose a nal time somewhat larger than 25,200 seconds, the denomi-
nator in the expression for dh/dt becomes zero because h = 0, and the expression for dh/dt
becomes undened. This causes diculties for the numerical algorithm. Thus it is best to
start with a small value for the nal time, and increase it. The plot is shown in the gure.
0 0.5 1 1.5 2 2.5 3
x 10
4
0
0.5
1
1.5
2
2.5
3
3.5
4
4.5
5
t (seconds)

h

(
f
e
e
t
)
Figure : for Problem 8.24.
8-27
25. (a) Write the equation as
dy
dt
= 4
2y
10 + 2t
Then create the following function le.
function ydot = salt(t,y)
ydot = 4-2*y/(10+2*t);
The following le solves the problem using the ode45 solver.
[t, h] = ode45(salt, [0, 10], 0);
plot(t,h),xlabel(Time t),ylabel(Salt Mass y)
The plot is shown in the gure.
0 1 2 3 4 5 6 7 8 9 10
0
5
10
15
20
25
30
Time t
S
a
l
t

M
a
s
s

y
Figure : for Problem 8.25.
8-28
(b) The variable coecient 2/(10 + 2t) varies from 2/10 to 2/30 as t varies from 0 to
10. Its mid-point value is 4/30. Using this value the model becomes
dy
dt
+
4
30
y = 4
Its response can be found from equation (8.4-10). It is
y(t) =
4
4/30
_
1 e
30t/4
_
= 30
_
1 e
30t/4
_
This equation predicts that y(10) = 30. The plot shows that the numerical solution gives
y(10) = 27 approximately. Thus we can have condence that the numerical solution is
correct.
26. The characteristic equation is
3s
2
+ 18s + 102 = 0
which has the roots s = 3 5i. Thus the time constant is = 1/3 and the steady state
response y
ss
= 10/102 will be reached at about t = 4/3. So we choose a nal time of t = 2,
somewhat greater than 4/3 in order to see the entire transient response. The imaginary
part 5i indicates that the response will oscillate with a radian frequency of 5, and a period
of 2/5.
We can use the function le msd shown in the text. It is
function xdot = msd(t,x)
global c f k m
A = [0,1;-k/m,-c/m];
B = [0;1/m];
xdot=A*x+B*f;
We can modify the script le shown in the text following the function le msd, by entering
the appropriate values for the parameters, as follows. Note that the plot function must be
modied because the problem specied that only y be plotted. The vector x(:,1) contains
the y values.
global c f k m
m = 3;c = 18;k = 102;f = 10;
[t, x] = ode23(msd, [0, 2], [0, 0]);
plot(t,x(:,1)),xlabel(t),ylabel(y)
When this le is executed, it produces the plot shown in the gure.
(b) Change the third line in the previous script le to
8-29
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
0
0.02
0.04
0.06
0.08
0.1
0.12
t
y
Figure : for Problem 8.26a.
[t, x] = ode23(msd, [0, 2], [0, 10]);
in order to use the initial values vector [0, 10]. The plot shown in the gure. The positive
initial velocity causes a greater overshoot.
8-30
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
0.2
0
0.2
0.4
0.6
0.8
1
t
y
Figure : for Problem 8.26b.
27. The characteristic equation is
3s
2
+ 39s + 120 = 0
which has the roots s = 5 and s = 8. Thus the dominant time constant is = 1/5 and
the steady state response y
ss
= 10/120 will be reached at about t = 4/5. So we choose a
nal time of t = 1.5, somewhat greater than 4/5 in order to see the entire transient response.
We can use the function le msd given in the text. It is
function xdot = msd(t,x)
global c f k m
A = [0,1;-k/m,-c/m];
B = [0;1/m];
xdot=A*x+B*f;
We can modify the script le shown in the text following the function le msd, by entering
the appropriate values for the parameters, as follows. Note that the plot function must be
modied because the problem specied that only y be plotted. The vector x(:,1) contains
the y values.
8-31
global c f k m
m = 3;c = 39;k = 120;f = 10;
[t, x] = ode23(msd, [0, 1.5], [0, 0]);
plot(t,x(:,1)),xlabel(t),ylabel(y)
When this le is executed, it produces the plot shown in the gure.
0 0.5 1 1.5
0
0.01
0.02
0.03
0.04
0.05
0.06
0.07
0.08
0.09
t
y
Figure : for Problem 8.27a.
(b) Change the third line in the previous script le to
[t, x] = ode23(msd, [0, 1.5], [0, 10]);
in order to use the initial values vector [0, 10]. The plot shown in the gure. The positive
initial velocity causes a greater overshoot.
8-32
0 0.5 1 1.5
0
0.1
0.2
0.3
0.4
0.5
0.6
t
y
Figure : for Problem 8.27b.
28. The equation has the general form
m y + ky = f(t)
where f(t) = 10 sin t. The state variable form, with x
1
= y and x
2
=

(y), is
x
1
= x
2
x
2
=
k
m
x
1
+
1
m
f(t)
Create the following function le:
function xdot = mksine(t,x)
global m k omega
A = [0,1;-k/m,0];
B = [0;1/m];
f = 10*sin(omega*t);
xdot=A*y+B*f;
(a) The following script le uses the ode23 function to solve the equations and to plot
the forcing function and the solution for x
1
= y.
8-33
global m k omega
omega = 1;
m = 3;k = 75;
[t, x] = ode23(mksine, [0, 20], [0, 0]);
f = 10*sin(omega*t);
subplot(2,1,1)
plot(t,x(:,1)),xlabel(t),ylabel(y(t))
subplot(2,1,2)
plot(t,f),xlabel(t),ylabel(f(t))
The plot is shown in the gure.
0 2 4 6 8 10 12 14 16 18 20
0.1
0
0.1
t
y
(
t
)
0 2 4 6 8 10 12 14 16 18 20
10
5
0
5
10
t
f
(
t
)
Figure : for Problem 8.28a.
(b) Replace the second line in the previous le with omega = 5.1. The plot is shown in
the gure.
(c) Replace the second line in the previous le with omega = 10. The plot is shown in
the gure.
8-34
0 2 4 6 8 10 12 14 16 18 20
6
4
2
0
2
4
6
t
y
(
t
)
0 2 4 6 8 10 12 14 16 18 20
10
5
0
5
10
t
f
(
t
)
Figure : for Problem 8.28b.
8-35
0 2 4 6 8 10 12 14 16 18 20
0.1
0
0.1
t
y
(
t
)
0 2 4 6 8 10 12 14 16 18 20
10
5
0
5
10
t
f
(
t
)
Figure : for Problem 8.28c.
8-36
The natural frequency of a mass and spring is
n
=
_
k/m. For this particular mass
and spring, m = 3, k = 75, and
n
=
_
75/3 = 5 radians per unit time. When the
forcing frequency is below the natural frequency, as in part (a), the motion of the mass has
an overall sinusoidal variation with smaller ripples superimposed on the motion. These
ripples has the same period as the period corresponding to the natural frequency. Here this
period is P = 2/
n
= 1.26. You can see that the ripples in the plot have this period. The
period of the low frequency component of the motion shown on the plot is the same as the
period of the forcing function, which is 2 = 6.28.
When the frequency of the forcing function is near the natural frequency, the condition
called resonance occurs in which the displacement of the mass oscillates with a large
amplitude. This condition is shown in the gure for part (b), where the forcing frequency
= 5.1 is just slightly above the natural frequency. The amplitude of motion is much larger
than for parts (a) and (c).
The inertia of the mass prevents it from reacting to a rapidly-changing forcing function.
Thus, as long as the forcing frequency is above the natural frequency, the greater the forcing
frequency the smaller the amplitude of motion. This is shown in part (c).
29. The state variable form, with x
1
= y and x
2
= y, is
x
1
= x
2
x
2
= x
1
+ (1 x
2
1
)x
2
Create the following function le:
global mu
mu = 1;
[t, x] = ode45(vanderp, [0, 20], [2, 0]);
plot(t,x(:,1)),xlabel(t),ylabel(y(t))
Then use the following script le to solve the equation and plot x
1
= y.
function xdot = vanderp(t,x)
global mu
xdot(1) = x(2);
xdot(2) = mu*(1-x(1)^2)*x(2) -x(1);
xdot = [xdot(1);xdot(2)];
The plot is shown in the gure.
8-37
0 2 4 6 8 10 12 14 16 18 20
2.5
2
1.5
1
0.5
0
0.5
1
1.5
2
2.5
t
y
(
t
)
Figure : for Problem 8.29.
30. The state variable form, with x
1
= and x
2
=

(), is
x
1
= x
2
x
2
=
a(t) cos g sin )
L
Create the following function le:
function xdot = accbase(t,x)
global m b
L = 1; g = 9.81;
xdot(1) = x(2);
xdot(2) = ((m*t + b)*cos(x(1)) -g*sin(x(1)))/L;
xdot = [xdot(1);xdot(2)];
To solve the equation and plot the solution, create the following script le. The acceleration
a(t) has been expressed as the linear function a(t) = mt + b. Thus for cases (a) and (b),
m = 0 and b = 5. For case (c), m = 0.5 and b = 0.
global m b
8-38
m = 0; b = 5;
[t, x] = ode45(accbase, [0, 10], [0.5, 0]);
plot(t,x(:,1)),xlabel(t (seconds)),ylabel(theta(t) (radians))
For cases (b) and (c), change the third line to
[t, x] = ode45(accbase, [0, 10], [3, 0]);
The results are shown in the following three plots.
0 1 2 3 4 5 6 7 8 9 10
0.44
0.45
0.46
0.47
0.48
0.49
0.5
0.51
t (seconds)
t
h
e
t
a
(
t
)

(
r
a
d
i
a
n
s
)
Figure : for Problem 8.30.
8-39
0 1 2 3 4 5 6 7 8 9 10
3
2
1
0
1
2
3
t (seconds)
t
h
e
t
a
(
t
)

(
r
a
d
i
a
n
s
)
Figure : for Problem 8.30b.
0 1 2 3 4 5 6 7 8 9 10
3
2
1
0
1
2
3
4
t (seconds)
t
h
e
t
a
(
t
)

(
r
a
d
i
a
n
s
)
Figure : for Problem 8.30c.
8-40
31. (a) Modify the program shown in Example 8.6-2 as follows:
R = 0.8;L = 0.003;c =0;
K_T = 0.05;K_e = 0.05;I = 8e-5;
A = [-R/L,-K_e/L;K_T/I,-c/I];
disp(The roots are:)
eig(A)
disp(The time constants are:)
-1./real(eig(A))
The results for the roots are s = 219.1303 and s = 47.5364. The time constants
are: 0.0046 and 0.0210. The dominant time constant is 0.021 seconds. Thus it will take
approximately 4(0.021) = 0.084 seconds for the motor speed to become constant if the
applied voltage is switched from 0 volts to a constant nonzero value.
(b) Because the motor model is a linear set of dierential equations, we can use either
an ode function or the step function to solve the equations. To use the ode23 function, rst
create the following function le, which is based on the state variable equations (8.6-10)
and (8.6-11). Note that the rst state variable is current; the second is velocity.
function xdot = dcmotor1(t,x)
global c I K_T K_e L R
A=[-R/L,-K_e/L;K_T/I,-c/I];
B=[1/L;0];
v=20;
xdot=A*x+B*v;
Then create the following script le, like the third le given in Example 8.6-3. Choose a
nal time of 0.1, which is slightly larger than four time constants.
global c I K_T K_e L R
R = 0.8;L = 0.003;c = 0;
K_T = 0.05;K_e = 0.05;I = 8e-5;
[t, x] = ode23(dcmotor1, [0, .1], [0, 0]);
subplot(2,1,1)
plot(t,x(:,1)),xlabel(Time (secs)),ylabel(Current (amps))
subplot(2,1,2)
plot(t,x(:,2)),xlabel(Time (secs)),ylabel(Speed (rad/sec))
The resulting plots are shown in the gure.
To solve the problem using the step function, rst create the state space model with
the following script le:
8-41
0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1
0
5
10
15
20
Time (secs)
C
u
r
r
e
n
t

(
a
m
p
s
)
0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1
0
100
200
300
400
Time (secs)
S
p
e
e
d

(
r
a
d
/
s
e
c
)
Figure : for Problem 8.31b.
R = 0.8;L = 0.003;c = 0;
K_T = 0.05;K_e = 0.05;I = 8e-5;
A = [-R/L,-K_e/L;K_T/I,-c/I];
B = [1/L;0];
C = [1, 0; 0,1];
D = 0;
sys = ss(A,B,C,D);
The unit step response can be plotted with the following command: step(sys). To nd
the response for v = 20, replace the line B=[1/L;0]; with B=[20/L;0];. It will look like
the plots shown in the gures.
(c) Create the following function le, like the function le dcmotor given in Example
8.6-3.
function xdot = dcmotor2(t,x)
global c I K_T K_e L R
A = [-R/L,-K_e/L;K_T/I,-c/I];
B = [1/L;0];
if t < 0.05;
v = 400*t;
8-42
elseif t <= 0.2
v = 20;
elseif t <= 0.25
v = -400*(t-.2) + 20;
else
v = 0;
end
xdot=A*x+B*v;
The following script le solves the equations and plots the applied voltage and the speed.
global c I K_T K_e L R
R = 0.8;L = 0.003;c = 0;
K_T = 0.05;K_e = 0.05;I = 8e-5;
t1=[0:.001:.05];
t2=[.051:.001:.2];
t3=[.201:.001:.25];
t4=[.251:.001:.3];
tp=[t1,t2,t3,t4];
v1=400*t1;
v2=20*ones(1,length(t2));
v3=-400*(t3-.2)+20;
v4=0*ones(1,length(t4));
v=[v1,v2,v3,v4];
[t, x] = ode23(dcmotor4, [0, .3], [0, 0]);
subplot(2,1,1)
plot(tp,v),xlabel(Time (secs)),ylabel(Applied Voltage (volts)), ...
axis([0 .3 0 25])
subplot(2,1,2)
plot(t,x(:,2)),xlabel(Time (secs)),ylabel(Speed (rad/sec)), ...
axis([0 .3 0 450])
The plot is shown in the gure.
8-43
0 0.05 0.1 0.15 0.2 0.25
0
5
10
15
20
25
Time (secs)
A
p
p
l
i
e
d

V
o
l
t
a
g
e

(
v
o
l
t
s
)
0 0.05 0.1 0.15 0.2 0.25
0
100
200
300
400
Time (secs)
S
p
e
e
d

(
r
a
d
/
s
e
c
)
Figure : for Problem 8.31c.
8-44
32. The script le is
left = [10, 3, 7];
right = 1;
sys = tf(right,left);
[A, B, C, D] = ssdata(sys)
This le produces the following results.
A =
_
0.3 0.7
1 0
_
B =
_
0.25
0
_
C =
_
0 0.4
_
D = [0]
33. The script le is
left = [10, 6, 2];
right = [3, 1];
sys = tf(right,left);
[A, B, C, D] = ssdata(sys)
This le produces the following results.
A =
_
0.6 0.4
0.5 0
_
B =
_
1
0
_
C =
_
0.3 0.2
_
D = [0]
34. The script le is
A = [-4, -1; 2, -3];
B = [2; 5];
C = [1, 0];
D = [0];
sys = ss(A,B,C,D);
[right, left] = tfdata(sys, v);
This le produces the following results: right = [0 2] and left = [1 7 14]. Thus
the reduced form model is
x
1
+ 7 x
1
+ 14y = 2u
8-45
35. (a) The script le is
A = [0, 1; -5, -2];
B = [0; 1]:
C = [1, 0];
D = [0];
sys = ss(A,B,C,D);
initial(sys, [5,3])
The resulting plot is shown in the gure.
Time (sec.)
A
m
p
l
i
t
u
d
e
Initial Condition Results
0 1 2 3 4 5 6
2
1
0
1
2
3
4
5
6

Figure : for Problem 8.35a.
8-46
(b) The script le is
A = [0, 1; -5, -2];
B = [0; 10]:
C = [1, 0];
D = [0];
sys = ss(A,B,C,D);
step(sys)
Note that we have included the eect of the step input magnitude in the matrix B = [0;
10]. The resulting plot is shown in the gure.
Time (sec.)
A
m
p
l
i
t
u
d
e
Step Response
0 1 2 3 4 5 6
0
0.5
1
1.5
2
2.5

Figure : for Problem 8.35b.
36. (a) To convert to state space form, let x
1
= y and x
2
= y. Then the model is
x
1
= x
2
x
2
= 2x
1

2
5
x
2
+
1
5
f
Thus the models matrices are
A =
_
0 1
2
2
5
_
B =
_
0
1
5
_
8-47
To plot y = x
1
, choose
C =
_
1 0
_
D = [0]
The given initial values are y(0) = x
1
(0) = 10 and y(0) = x
2
(0) = 5. The script le to
nd the free response is
A = [0, 1; -2, -2/5];
B = [0; 1/5]:
C = [1, 0];
D = [0];
sys = ss(A,B,C,D);
initial(sys, [10,-5])
The plot is shown in the gure.
Time (sec.)
A
m
p
l
i
t
u
d
e
Initial Condition Results
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
2
0
2
4
6
8
10

Figure : for Problem 8.36a.
(b) The script le to nd the step response is
A = [0, 1; -2, -2/5];
B = [0; 1/5]:
C = [1, 0];
D = [0];
8-48
sys = ss(A,B,C,D);
step(sys)
The plot is shown in the gure.
Time (sec.)
A
m
p
l
i
t
u
d
e
Step Response
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
0
0.02
0.04
0.06
0.08
0.1
0.12

Figure : for Problem 8.36b.
(c) The script le to nd the total response is
A = [0, 1; -2, -2/5];
B = [0; 1/5]:
C = [1, 0];
D = [0];
sys = ss(A,B,C,D);
t=[0:.01:5];
[y1,x1] =initial(sys,[10,-5],t);
[y2,x2]=step(sys,t);
y3=y1+y2;
u=stepfun(t,0);
[y4]=lsim(sys,u,t,[10,-5]);
plot(t,y3,t,y4),xlabel(t),ylabel(y)
8-49
The plot is shown in the gure. The two curves are indistinguishable. Note that in this
problem the total response is very similar to the free response, because the steady-state
step response is very small compared to the free response (y
ss
= 0.2).
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
0
1
2
3
4
5
6
7
8
9
10
t
y
Figure : for Problem 8.36c.
37. From Example 8.6-2 the smallest time constant is 0.0041 sec. Thus we chose a time
increment that is much smaller than 0.0041, say 0.0041/20 2 10
4
. The script le is
shown in the gure. The time vectors t1, . . ., t4 are the time vectors for each of the four
phases (the three trapezoidal segments and the nal rest phase). The vectors v1, . . ., v4
contain the applied voltage v(t) for each of the four phases.
dt = 2e-4;
t1 = [0:dt:0.1-dt];
t2 = [0.1:dt:0.4-dt];
t3 = [0.4:dt:0.5-dt];
t4 = [0.5:dt:0.6];
v1 = 100*t1;
v2 = 10*ones(1,length(t2));
v3 = -100*(t3-0.4)+10;
v4 = zeros(1,length(t4));
t = [t1,t2,t3,t4];
8-50
v = [v1,v2,v3,v4];
subplot(2,1,1)
plot(t,v),axis([0 0.6 0 12]),axis([0 .6 0 12]),xlabel(Time (secs)),...
ylabel(Applied Voltage (volts))
R = 0.6;L = 0.002;c = 0;
KT = 0.04;Ke = 0.04;I = 6e-5;
A = [-R/L,-Ke/L;KT/I,-c/I];
B = [1/L;0];
C = [0,1];
D = 0;
sys = ss(A,B,C,D);
[y, t] = lsim(sys,v,t);
subplot(2,1,2)
plot(t,y),axis([0 .6 0 300]),xlabel(Time (secs)),...
ylabel(Speed (rad/sec))
The plots are shown in the gure.
0 0.1 0.2 0.3 0.4 0.5
0
2
4
6
8
10
12
Time (secs)
A
p
p
l
i
e
d

V
o
l
t
a
g
e

(
v
o
l
t
s
)
0 0.1 0.2 0.3 0.4 0.5
0
50
100
150
200
250
300
Time (secs)
S
p
e
e
d

(
r
a
d
/
s
e
c
)
Figure : for Problem 8.37.
8-51
38. The square function cannot be used here because it creates a periodic square wave,
and we need a single square pulse. The script le is
sys = tf(1,[0.1,1]);
t = [0:0.001:1];
u = 10*(stepfun(t,0)-stepfun(t,0.2));
[y, t] = lsim(sys,u,t);
plot(t,y,t,u),axis(([0 0.7 0 12]),xlabel(Time (secs)),...
ylabel(Capacitor Voltage (volts))
The plot is shown in the gure.
0 0.1 0.2 0.3 0.4 0.5 0.6
0
2
4
6
8
10
12
Time (secs)
C
a
p
a
c
i
t
o
r

V
o
l
t
a
g
e

(
v
o
l
t
s
)
Figure : for Problem 8.38.
8-52
0 500 1000 1500 2000 2500 3000
2.5
2
1.5
1
0.5
0
0.5
1
1.5
2
2.5
t
y
Figure : for Problem 8.39.
39. Put the model in state variable form as follows. Let x
1
= y and x
2
= y.
x
1
= x
2
x
2
= x
1
+ (1 x
2
1
)x
2
Create the following function le.
function xdot = vand1(t,x);
mu = 1000;
xdot = [x(2); -x(1) + mu*(1-x(1)^2)*x(2)];
The following script le uses the ode23s function.
t, x] = ode23s(vand1, [0, 3000], [2, 0]);
plot(t,x(:,1)),xlabel(t),ylabel(y)
The plot is shown in the gure. The function ode45 fails to converge to a solution for this
problem, but it can obtain a solution for nonsti values of , such as = 1.
8-53
40. The approach is similar to that followed in the text, except that here the model is
fourth order, and we must solve the equations over three time intervals instead of two. The
le throwode.m plays the role of the le ballode.m in the text. The le bounce.ode calls
the ode45 solver and plots the response.
The equations of motion are

h = g x = 0
where h(t) is the balls height and x(t) is its horizontal displacement. The given initial
values are h(0) = x(0) = 0,

h(0) = 30 sin 30

, x(0) = 30 cos 30

. To put the model into


state variable form, let y
1
= h, y
2
=

h, y
3
= x, and y
4
= x. Then
y
1
= y
2
y
2
= g
y
3
= y
4
y
4
= 0
and y
1
(0) = y
3
(0) = 0, y
2
(0) = 30 sin 30

, and y
4
(0) = 30 cos 30

.
% file throwode.m
function[value,isterminal,direction] = throwode(t,y,flag)
if(nargin<3)|isempty(flag)
value = [y(2);-9.81;y(4);0];
elseif flag == events
value = y;
isterminal = [1;0;0;0];
direction = [-1;0;0;0];
else
error([unknown flagflag.]);
end
In the following le, note that we must update the initial conditions after each bounce
because the ball is translating horizontally as well as vertically. The variables SV and SH
are the vertical and horizontal components of the initial velocity.
% bounce.m
options = odeset(Events,on);
SV = 30*sin(30*pi/180);
SH = 30*cos(30*pi/180);
[t1,y1] = ode45(throwode,[0,10],[0,SV,0,SH],options);
[t2,y2] = ode45(throwode,[t1(length(t1)),10],...
[0,-0.8*y1(length(t1),2),SH*t1(length(t1)),SH],options);
[t3,y3] = ode45(throwode,[t2(length(t2)),10],...
[0,-0.8*y2(length(t2),2),SH*t2(length(t2)),SH],options);
t = [t1;t2;t3];y = [y1;y2;y3];
plot(y(:,3),y(:,1)),axis([0 200 0 200]),xlabel(Distance (m)),...
8-54
0 20 40 60 80 100 120 140 160 180 200
0
2
4
6
8
10
12
Distance (m)
H
e
i
g
h
t

(
m
)
Figure : for Problem 8.40.
ylabel(Height (m))
The plot is shown in the gure.
8-55
Figure : for Problem 8.41.
41. The gure shows the Simulink digram for the sine wave input.
8-56
Figure : for Problem 8.42.
42. The gure shows the Simulink digram. Note that initial values were not specied
for y and y. Nonzero values for these can be specied as the initial conditions of the two
integrators. Their values will aect the simulation results.
8-57
Figure : for Problem 8.43.
43. The gure shows the Simulink digram. Note that the given value of Q = 10 might not
be large enough to keep the temperature between 69

and 71

.
8-58

You might also like