Math 308, Matlab assignment 3

advertisement
Math 308, Matlab assignment 3
due March 26 in class
1. A mass of 1 kg is attached to an (idealized) spring with the spring constant 100 N/m2 and zero
damping. The mass is at rest at the equilibrium position of the spring. Then, starting at time 0, an
external force cos 9t is applied to the mass.
(a) Use dsolve to find the position of the mass as a function of time. Write down the formula
in your report.
(b) Use ezplot to plot your solution on the interval [−10, 10]. If you do this correctly, you
should observe the phenomenon of “beats”. It is encountered in practice with speakers that
have feedback.
2. A mass of 1 kg is attached to a spring with the spring constant 5 N/m2 and the damping constant
2 N/m. The mass is at rest at the equilibrium position of the spring. Then, starting at time 0, an
external force cos t is applied to the mass.
(a) dsolve does not work on this problem (try it if you want), so we will have to use a numerical solver ode45. First, we need to write the second order ODE
my 00 + by 0 + ky = F (t)
as a system of two first-order ODE
u01 = u2 ,
b
k
1
u02 = − u2 − u1 + F (t).
m
m
m
0
where u1 = y, u2 = y . Now we create an M-file (see Assignment 2)
function uprime = Exc32(t,u)
uprime = zeros(2,1);
uprime(1) = u(2);
uprime(2) = -(b/m)*u(2) - (k/m)*u(1) + (1/m)*cos(t);
and save it as Exc32.m (or whatever name you want to use). In the actual file you will use
the numeric values of m, k, b, or you can choose to pass them in as parameters.
(b) Now use ode45 on the interval [0, 20] (again, see Assignment 2) to solve the system; the
syntax is
[t,u] = ode45(...,[0;0])
where [0; 0] are the initial conditions for u1 = y and u2 = y 0 . We can extract just u1 from u
by using u(:,1).
(c) By the method of undetermined coefficients, we can find a particular solution
1
1
(1)
yp (t) =
sin t + cos t.
10
5
This is exactly the steady state solution (why?). On one plot, graph the full solution, the
steady state solution, and the transient solution (which you need to find first, but since you
know the full solution and the steady-state solution, that is easy).
1
3. A mass of 1 kg is attached to a spring with the spring constant 1 N/m2 and the damping constant
b N/m. The mass is at rest at the equilibrium position of the spring. Then, starting at time 0, an
external force cos t is applied to the mass. Note that for b = 0, the resonance frequency of the
system is 1.
(a) Write the corresponding M-file for the function Exc33(t,u,b), where b is passed in as a
parameter.
(b) For b = 0.5, compute the solution on the interval [0, 100] using
[t,u]=ode45(@Exc33,[0,100],[0;0],[],0.5);
and plot t versus u(:,1). What is the frequency gain?
(c) Redo part (b) for b = 0.1. What is the frequency gain?
4. (Problem 5.2.19 of the textbook). We will numerically solve the initial value problem
x0 = 4x + y;
0
y = −2x + y;
x(0) = 1,
y(0) = 0.
(a) Write an M-file describing this system. You can call u1 = x and u2 = y if you prefer.
(b) Use ode45 to compute the solution of the system, and plot it on the interval [0, 5] (using
simply plot(t,u)). Does your plot agree with the answer at the end of the textbook?
Note that e5 ≈ 150, e10 ≈ 2.2 · 104 , e15 ≈ 3 · 106 .
Download