% MITES08: Underdamped Oscillations [criticallydampedSHM.m]
% June 28, 08 [Sat.]
% Plots critically damped simple harmonic motion.

clear;

% Case 2: Critically damped oscillation.

% ***** USER: Change the parameters and explore *****
% See Pg. 37 of lecture notes for meaning of these two free parameters C1 & C2:
C1 = 1;  
C2 = 5;
gamma = 1;

% ***** Change the following parameter for plotting **** 
tf = 10;  % For how long would you like to observe the motion in the plot?

% After solving EOM for critically damped oscillation (Pg.36 & 37 of lecture notes)
% we obtain x(t) = position of particle
t = linspace(0, tf,1000); % Time: from 0s to tf in 1000 increments.
criticallydampedSHO = exp(-gamma*t).*(C1+t*C2);

% Plot critically damped case:
plot(t, criticallydampedSHO, '-r');
hold on
xlabel('time');
ylabel('Position of criically damped SHO');
title('Motion of particle in critically damped simple harmonic oscillator (SHO)');
hold off

