Using Sound to "Illustrate" Mechanical Vibrations


Objective:   When modeling the mechanical vibrations arising from spring-mass systems, it is customary to illustrate the displacement of the mass as it oscillates about the equilibrium position using graphs or animations. This demo makes use of computer generated sound to "illustrate" oscillatory solutions.

Level:  A first course in ordinary differential equations.

Prerequisites:  Students should know how to solve homogeneous and nonhomogeneous second order linear ODEs and be familiar with the various forms of the solutions.

Platform:  This demo utilizes MATLAB (version 5.3) or Mathematica (version 2.2 or higher) software running on a PC platform.   The accompanying MATLAB graphical user interface application has not been tested on Mac or Unix platforms.

Instructor's Notes:  A spring-mass system gives rise to a second order initial value problem  of the form 


where m, and k are positive constants, c is a nonnegative constant, y = y(t) is the displacement of the mass at time t, and f(t) is an applied force. 

When the parameters are such that , solutions are oscillatory.  The nature of solutions depends on whether the system is damped (c > 0) or undamped (c = 0) and on whether the system is free (f(t) = 0 for all t in the relevant interval) or forced (f(t) is not identically zero in the interval).

In the case where f(t) = 0 and c = 0, the resulting initial value problem can be written as


The natural frequency of the oscillation is .  

If an external force with frequency ,  , oscillations will become unbounded when . If the forcing frequency is close to the natural frequency, beats occur.

If the system is damped with no forcing, solutions have the form 

so oscillations decay with increasing t.  The motion is quasiperiodic.  If , the motion is characterized by a transient and steady state.

Audible waves originate from strings that vibrate within the frequency range 20 Hz to 20,000 Hz.  This demo involves utilizing sound generating capabilities of MATLAB or Mathematica to illustrate the nature of the solutions to the differential equation when oscillations are sustained. 

To generate sound using  MATLAB or Mathematica, sample code is given below.

MATLAB:  To generate a sound of 440 Hz for 10 seconds using a sample rate of  8192 (default) 

t = 0:1/8192:10;
y = cos(2*pi*440*t);
% sound plays output with 
% amplitude between -1 and 1
plot(x,y)  % generates graphic

Note:  If the amplitude > 1, using the sound command causes output to be clipped.  Use soundsc or multiply y by 1/max(y) to obtain amplitude between -1 and 1.

Play these sounds: The following illustrate a MATLAB graphical user interface tools for this demo. Various scenarios of oscillatory functions in the spring-mass problem can be illustrated by changing the natural and forcing frequencies.

Push the Play/Plot button to hear the sound.  If your playback application does not support streaming, it may be necessary to allow the file to download and then re-play.

The MATLAB graphical user interfaces for the free and damped cases are available by downloading and extracting the files from  (damping present)  Contains:  sound_d.m and sound_d.mat (no damping case)  Contains sound_nod.m and sound_nod.mat


Each archive file contains two files necessary to run the graphical user interface.  You must make sure that each file is in the MATLAB path.  To download, simultaneously press the shift key and left click.

Mathematica:  To generate a sound of 440 Hz for 10 seconds using a sample rate of around 8000 (default): 

y[t_]=Cos[2 Pi*400 t]
Play[y[t],{t,0,10}]   * renders sound and graphic


Credits:  This demo and MATLAB m-files were submitted by

Dr. Lila F. Roberts
College of Information & Mathematical Sciences

Clayton State University
Morrow, GA 30260


and is included in Demos with Positive Impact with her permission.



LFR 1/23/00.    Last updated 9/15/2010 DRH

Previous counter data was lost.


Visitors since 2/1/2005