function [x, v] = dhmotion(A, m, k, b, phi, t)
%DHMOTION Damped harmonic oscillator motion.
%   [X, V] = DHMOTION(A, M, K, B, PHI, T) computes the postion X
%   and envelope V of a simple damped harmonic oscillator having
%   amplitude A, mass M, spring constant K, damping constant B, and
%   phase PHI, at all times in T.

v = A * exp(-b * t / (2 * m));
x = v .* cos(sqrt(k / m) * t + phi);

end

