freqs  = 5:15;
num = numel(freqs);
lengths = 1./sqrt(freqs);
piover6 = pi/6;


figure('Units','normalized','Position',[0 0 1 1])
axis square
axis([-0.3 0.3 -0.5 0]);
axis off;
org=zeros(size(freqs));
xpos=zeros(size(freqs));
ypos=zeros(size(freqs));
pendula =  line([org;org],[org;org],'LineWidth',1,'Marker','.','MarkerSize',25 ...
                ,'Color',[0 0 0],'visible','off' );

% Open the avi file
vidObj = VideoWriter('pendula_wave.mp4');
open(vidObj);

count =0;
for t=0:0.001:1
    count=count+1;
    omegas = 2*pi*freqs*t;
    xpos = sin(piover6*cos(omegas)).*lengths;
    ypos = -cos(piover6*cos(omegas)).*lengths;

    for i=1:num
     set(pendula(i),'visible','on');
     set(pendula(i),'XData',[0 xpos(i)]);
     set(pendula(i),'YData',[0 ypos(i)]);
     drawnow
    end
     currFrame = getframe;
     writeVideo(vidObj,currFrame)

     F(i) = getframe;
end

% Close the file.
close(vidObj);