Harmonic Oscillator Explorer

Illustrates a suite of symbolic solutions for a forced damped harmonic oscillator and parameter extraction in the presence of transients.

You are now following this Submission

This script derives and illustrates symbolic solutions to the equation of motion for a forced damped harmonic oscillator using MATLAB symbolic tools. Harmonic, step, ramp, and impulse forcing functions are considered and the impulse response used as a Green's function to rederive the step function response.
The full solution to the harmonically driven damped harmonic oscillator exhibits an interesting beat phenomenon often observed but ignored in laboratory experiments with driven mechanical and electrical oscillators in introductory courses. Given the full analytic solution, one can use nonlinear regression to determine the initial conditions and system parameters from any combination of transient and steady-state behavior. This is illustrated by fitting simulated data in which the beats are evident as generally occurs when scanning the drive frequency over a resonance.
The response of a harmonic oscillator to a general prescribed external force is a topic of an intermediate university-level mechanics course. This script may interest university students and instructors in physics and engineering. 'Try this' suggestions are included for further exploration.

Cite As

Duncan Carlsmith (2026). Harmonic Oscillator Explorer (https://in.mathworks.com/matlabcentral/fileexchange/123715-harmonic-oscillator-explorer), MATLAB Central File Exchange. Retrieved .

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
1.01

Added interactive_examples tag

1.0.0