# Second Order Vibration Simulation in MATLAB

#### Forced Sinusoidal Frequency Response and Free Response

This simulation tool in MATLAB displays a second order forced vibration system's response to sinusoidal input (the frequency response), and has the following features:
• Fully simulate the sinusoidal response of any spring-mass-damper or any series RLC circuit (when time and frequency units are normalized)
• View input and response together with gain and phase-lag on Bode plots
• Real-time slider control of parameters (input frequency, damping, etc)
• Option to display response split into transient and steady-state parts
• Simulate undamped response (beats, pure resonance) by setting $$\delta$$ to $$0$$ (where $$\delta$$ is defined as $$\gamma/(2m)$$ in the mechanical system and as $$R/(2L)$$ in the electrical system)
• Simulate free response by setting the input amplitude $$A$$ (and the input frequency $$\omega$$) to $$0$$
• For convenience, the natural undamped frequency $$\omega_0$$ is fixed at 1, so that the input frequency $$\omega$$ remains normalized

The Vibration Equation $\boxed{ \dfrac{d^2y}{dt^2} + 2\delta \dfrac{dy}{dt} + \omega_0^2 y = \omega_0^2 A \cos(\omega t - \theta)},$ where the driving input (forcing term) $$A\cos(\omega t - \theta)$$ produces the responce $$y = y(t)$$. Thus $$\omega$$ is the input frequency, $$A$$ is the driving (input) amplitude, $$\theta$$ is the input phase-lag, and:
• In a mechanical spring-mass-damper system with mass $$m$$, spring-constant $$k$$, and damping ratio $$\gamma$$, \begin{aligned} \delta & := \frac{\gamma}{2m},\\ \omega_0 & := \sqrt{\frac{k}{m}},\\ A \cos(\omega t - \theta) & := \text{the driving displacement (input), and}\\ y & := \text{the displacement of the mass (response).} \end{aligned}
• In an electrical series RLC circuit with inductor $$L$$, capacitor $$C$$, and resistor $$R$$, \begin{aligned} \delta & := \frac{R}{2L},\\ \omega_0 & := \frac{1}{\sqrt{LC}},\\ A \cos(\omega t - \theta) & := \text{the driving (input) voltage (emf), and}\\ y & := \text{the capacitor voltage (response).} \end{aligned}
The $$Q$$-factor is defined as $$Q := \omega_0/(2\delta)$$, so $$Q = \frac{1}{\gamma}\sqrt{km}$$ in the mechanical system, and $$Q = \frac{1}{R}\sqrt{\frac{L}{C}}$$ in the electrical system.

The MATLAB m-file is available.

Written by Abhijit Dasgupta for MTH-3720 (Differential Equations) at UDMercy