Duffing Oscillator Phase Space Animator

This MATLAB code provides an elegant visualization of the Duffing oscillator's phase space dynamics.

You are now following this Submission

This MATLAB code provides an elegant visualization of the Duffing oscillator's phase space dynamics, specifically demonstrating the system's sensitivity to initial conditions. The implementation features a sophisticated animation of two nearby trajectories, highlighted through an aesthetically pleasing dark-themed interface.
Key Features
  • Interactive visualization of the Duffing oscillator's phase space
  • Simultaneous animation of two trajectories with nearby initial conditions (0.5 and 0.51)
  • Clear visual distinction between trajectories using contrasting colors
Technical Details
  • System Parameters:
  • Damping coefficient (γ) = 0.1
  • Linear stiffness (α) = -1
  • Non-linear stiffness (β) = 1
  • External force amplitude (F) = 2
  • Forcing frequency (ω) = 2.4
Requirements
  • MATLAB R2019b or newer
  • Video Writer support for MP4 format
Usage
  1. Simply run the script to generate the animation
  2. The animation will be automatically saved as 'duffing_animation.mp4'
  3. Parameters can be easily modified at the beginning of the script
Customization Options
  • Adjust trail_length for different trajectory history lengths
  • Modify step variable to change animation speed
  • Color schemes can be customized through the animation parameters
  • Video quality and frame rate are adjustable via VideoWriter properties
Applications
  • Educational demonstrations of chaos theory
  • Research in nonlinear dynamics
  • Teaching material for physics and mathematics courses
  • Visualization of sensitive dependence on initial conditions
Author Notes
This implementation focuses on visualizing the butterfly effect in the Duffing oscillator by tracking two nearly identical initial conditions. The dark theme and color choices are optimized for clarity and visual appeal, making it ideal for both educational and research purposes.

Cite As

Sathyanarayan Rao (2026). Duffing Oscillator Phase Space Animator (https://uk.mathworks.com/matlabcentral/fileexchange/174490-duffing-oscillator-phase-space-animator), 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.0.0