I am working on the following problem:
========================================
We wish to examine the motion of a damped harmonic oscillator. The small amplitude oscillation of a unit mass attached to a spring is given by the formula y = e−(R/2)t sin(ω1t ), where ω2 1 = ω2 o − R2/4 is the square of the natural frequency of the oscillation with damping (i.e., with resistance to motion); ω2 o = k is the square of the natural frequency of undamped oscillation; k is the spring constant; and R is the damping coefficient. Consider k = 1 and vary R from 0 to 2 in increments of 0.5. Plot y versus t for t from 0 to 10 in increments of 0.1.
========================================
My main problem with this problem is that I am told to evaluate y for R=0:0.5:2, but plot over the range of t=0:0.1:10. How can this work, if y is 1×5 and t is 1×101?
Here is my code, minus the line for t, which I make the same as R to get y, but then try to change when going to plot (doesn't work):
========================================
k= 1; %spring constant
R=[0:0.5:2]; %damping coeff
w0=sqrt(k);
w1=sqrt((w0^2)-R.^2/4);
y=exp(-(R./2).*t).*(sin(w1.*t));
plot(t,y)
Best Answer