Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Caluclus QUESTION (need MATLAB code to solve) Find the formula for the general s

ID: 3575899 • Letter: C

Question

Caluclus QUESTION (need MATLAB code to solve)

Find the formula for the general solution to the harmonic oscillator that is governed by the equation d2x/dt2 = (-1/6)x     (k = 1 and m= 6)

(a) Find the solution that satisfies the conditions x(0) = 4.1 and x' (0) = 6.5

Create a plot of the solution. Notice the slope of the curve at t = 0 ... it should be 6.5.

(b) Use MATLAB to plot the solution to the differential equation in (a) with a damping term added. If c is the damping constant, determine the smallest value of c for which the solution never becomes negative.

Hint: When plotting the solution, use the PlotRange option of Plot and plot a large enough interval to clearly see whether the solution ever becomes negative

Explanation / Answer

a) Without damping:

oscillator.m

function dxdt = func(t, x)
dxdt = [x(2); (-1/6)*t];

script.m

[t x] = ode23(@oscillator, [0 1000], [4.1 6.5]);

figure
plot(t, x(1));

b) With damping term:

oscillator.m

function dxdt = func(t, x)
c = 0.1;
dxdt = [x(2); (-1/6)*t-c*x(1)];

script.m

[t x] = ode23(@oscillator, [0 1000], [4.1 6.5]);

figure
plot(t, x(1));

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote