This is a simple MATLAB code I created which simulates the way a wave propagates through a medium. I wanted to simulate the wave machine created by *John N. Shive* at *Bell Telephone laboratories*. The lecture that introduced the machine can be seen below.

I wanted to create a wave simulation code with very simple concepts. The original wave machine consists of thin metal bars that are connected. The wave motion comes from the displacement of energy between the metal bars via torsion. Since I already knew about how I could numerically simulate a spring the problem became: “How can I convert the problem of the wave machine into connected springs?”. I figured using only springs and some linear communication between nodes would suffice.

The simulation works by using simple Euler integration to solve the spring equation for a bunch of vertical springs.

dis = pos - ideal; acc = -k*dis./m - d*vel./m; vel = vel + acc*dt; pos = pos + vel*dt;

Now, in order to get a propagating wave, I have to allow some horizontal communication of the nodes of the “rope” to occur. The horizontal communication is applied to the ideal positions of the springs. I simply divide the ideal positions from its two adjacent neighbours.

The code of this communication can be seen below:

for i = 2:n-1 ideal(i-1) = ideal(i-1) + pos(i)*0.5; ideal(i+1) = ideal(i+1) + pos(i)*0.5; end

In order to let an end move *freely *you have to add back the displacement you just smoothed in the loop above.

ideal(n-1) = ideal(n-1) + pos(n-1)*0.5; ideal(2) = ideal(2) + pos(2)*0.5;

Using this simple model, we can now recreate the first experiments illustrated by the video above using the “Shive machine”. Cool huh?