Pendulum Wave Demonstration With Matlab

I’ve decided to build a pendulum wave and write an Instructable to document the process.

In the meantime, here’s a matlab demonstration showing how I hope it will behave. Matlab function is posted after the video.


%Created by Eric Cox - https://ericboy.wordpress.com - 5/17/2012

function [] = PWT(n,f,df,t)

%This function plots pendulum wave motion as seen from the top view.
%
% n is the number of pendulums, f is the frequency of the first pendulum
% in the wave, df is the incremental change in frequency between pendulums
% (added), t is the time to display the animation

%set initial time to zero.
t_n=0;

%preallocate lengths of matrices.
y=(1:n);
x=(1:n);

while (t>t_n)

%for each value in x,y matrices, populate with value at current t.
for j=1:n
x(j)=j;
y(j)=sin(2*pi*(f+(j)*df)*t_n+pi/2);
end

%Plot pendulum wave
plot(x,y,’o’,’MarkerEdgeColor’,’k’,…
‘LineWidth’,2,…
‘MarkerFaceColor’,’b’,…
‘MarkerSize’,11);

%Define axis
axis([0 n+1 -1.5 1.5]);

%Increment loop time
t_n=t_n+1/30;

%Animation delay
pause(1/30);

end

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s