Chapter10 Prob35
Chapter10 Prob35
10.35 The differential equation for free motion of a spring-mass-damper system is:
d 2x dx
--------2 + 2γ ------ + k 2 x = 0
dt dt
dx
where k 2 = 48 N/m/kg, γ = 0.7 s–1, x ( 0 ) = 0 , and ------ = 0.2 m/s. Solve the ODE over the interval
dt t=0
dx
0 ≤ t ≤ 5 s, and plot x ( t ) and ------ (two separate figures on one page) as a function of t.
dt
(a) Use the user-defined function Sys2ODEsModEU that was written in Problem 10.20. For step size use
0.01 s.
(b) Use one of MATLAB’s built-in functions for solving ODEs.
Solution
To solve the problem the second-order ODE is rewritten as a system of two first-order ODEs. This is done
by introducing a new variable w, such that:
2
dx dw d x
w = ------ and ------- = -------2-
dt dt dt
With these definitions the system of two first-order ODEs is:
dx
------ = w with the initial condition x ( 0 ) = 0
dt
dw
------- = – 2γw – k 2 x with the initial condition w ( 0 ) = 0.2
dt
dx dw
(a) The differential equations ------ = w and ------- = – 2γw – k 2 x are written in a user-defined function called
dt dt
HW10_35aODEs:
The user-defined functions Sys2ODEsModEu (listed in the solution of Problem 10.20) and
HW10_35aODEs are used in the following script file to solve the problem and make the plots.
Excerpts from this work may be reproduced by instructors for distribution on a not-for-profit basis
for testing or instructional purposes only to students enrolled in courses for which the textbook
has been adopted. Any other reproduction or translation of this work beyond that permitted by
Sections 107 or 108 of the 1976 United States Copyright Act without the permission of the
copyright owner is unlawful.
2
h=0.01;
[t, x, w] = Sys2ODEsModEu(@HW10_35aODEs,ab,h,INI);
subplot(2,1,1)
plot(t,x)
xlabel('Time (s)')
ylabel('Position x (m)')
subplot(2,1,2)
plot(t,w)
xlabel('Time (s)')
ylabel('dx/dt (m/s)')
When the script file is executed the following figure that follows is displayed in the Figure Window.
0.03
0.02
Position x (m)
0.01
-0.01
-0.02
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
Time (s)
0.2
0.1
dx/dt (m/s)
-0.1
-0.2
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
Time (s)
dx dw
(a) The differential equations ------ = w and ------- = – 2γw – k 2 x are written in a user-defined function called
dt dt
HW10_35bODEs:
Excerpts from this work may be reproduced by instructors for distribution on a not-for-profit basis
for testing or instructional purposes only to students enrolled in courses for which the textbook
has been adopted. Any other reproduction or translation of this work beyond that permitted by
Sections 107 or 108 of the 1976 United States Copyright Act without the permission of the
copyright owner is unlawful.
3
MATLAB built-in function ode45 and HW10_35bODEs are used in the following script file to solve the
problem and make the plots.
When the script file is executed the following figure that follows is displayed in the Figure Window.
Excerpts from this work may be reproduced by instructors for distribution on a not-for-profit basis
for testing or instructional purposes only to students enrolled in courses for which the textbook
has been adopted. Any other reproduction or translation of this work beyond that permitted by
Sections 107 or 108 of the 1976 United States Copyright Act without the permission of the
copyright owner is unlawful.
4
0.03
0.02
Position (ft)
0.01
-0.01
-0.02
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
Time (s)
0.2
0.1
Velocity (ft/s)
-0.1
-0.2
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
Time (s)
Excerpts from this work may be reproduced by instructors for distribution on a not-for-profit basis
for testing or instructional purposes only to students enrolled in courses for which the textbook
has been adopted. Any other reproduction or translation of this work beyond that permitted by
Sections 107 or 108 of the 1976 United States Copyright Act without the permission of the
copyright owner is unlawful.