This is the entire problem. I am looking for help with part 3.(adsbygoogle = window.adsbygoogle || []).push({});

For the mass-spring system with damping, we obtain the following DE

my′′ + gammay′ + ky = 0, or y′′ + cy′ + omega^2y = 0, where c = gamma/m and omega^2 = k/m. Given m = 1,k = 4, gamma= 1, and initial conditions y(0) = 0.1, y′(0) = 0.

(1) Plot solutions y and v = y′ = dy/dt as functions of time.

(2) Plot v vs y (phase plot). Comment on the behavior of the curve.

(3) Plot the quantity E = 1/2mv^2 + 1/2ky^2 as a function of time. What do you observe?

(4) Show that dE/dt < 0 for gamma > 0 while dE/dt > 0 for gamma < 0 (analytically or by graphic).

For part 1

function Q2part1

m = 1; % mass [kg]

k = 4; % spring constant [N/m]

gamma = 1; % friction coefficient [Ns/m]

omega = sqrt(k/m); c = gamma/m;

y0 = 0.1; v0 = 0; % initial conditions

[t,Y] = ode45(@f,[0,10],[y0,v0],[],omega,c); % solve for 0<t<10

y = Y(:,1); v = Y(:,2); % retrieve y, v from Y

figure(1); plot(t,y,'b+-',t,v,'ro-'); % time series for y and v

%-------------------------------------------

function dYdt = f(t,Y,omega,c)

y = Y(1); v = Y(2);

dYdt = [ v ;-c*(v)-omega^2*y];

for part 2

function Q2part2

m = 1;

k = 4;

gamma = 1;

omega = sqrt(k/m); c = gamma/m;

y0 = 0.1; v0 = 0;

[t,Y] = ode45(@f,[0,10],[y0,v0],[],omega,c);

y = Y(:,1); v = Y(:,2);

figure(1); plot(v,y);

function dYdt = f(t,Y,omega,c)

y = Y(1); v = Y(2);

dYdt = [ v ;-c*(v)-omega^2*y];

I know that i need to plug in formulas for y (and v as well?) so that I have E(t), but is it as simple as solving for and plugging in y? I am in need of direction here I suppose...a nice big fat hint to put me in the correct direction.

**Physics Forums | Science Articles, Homework Help, Discussion**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# MatLab Spring Damping and Energy

**Physics Forums | Science Articles, Homework Help, Discussion**