% pendule_N.m
%
% P. Flandrin

C = 0; % 1 si figure récapitulative

N = 230; % 512
dt = 2*0.6; % 3*O.6
l = linspace(1,10,N);
ls = ones(size(l));

k0 = 40;

L = l(k0);
f = sqrt(l)/.05;
F = f(k0);
fs = F*ones(size(f));
thetas = sin(2*pi*N*dt./fs)/5.*L./ls;
theta = sin(2*pi*N*dt./f)/5.*L./l;
theta0 = sin(2*pi*(1:N)*dt./F)/5;

figure(1)
clf

pause

P = .1;

for k = k0:N
	
	subplot(121)

 	plot([0 -L*sin(theta0(k))],[0 -L*cos(theta0(k))])
 	hold on
	plot([0 -L*sin(theta0(k))],[0 -L*cos(theta0(k))],'.','MarkerSize',15)
	plot(-L*sin(theta0(k)), -L*cos(theta0(k)),'.','MarkerSize',45)
	plot([0 10-l(k0)],[0 0])
 	plot([0 10-l(k0)],[0 0],'.','MarkerSize',15)
	axis([-12 12 -16 8])
	set(gca,'XTick',[]);
	set(gca,'YTick',[]);
	hold off
	pause(P)
	
	subplot(122)
	
	plot(k,-theta0(k),'.r','MarkerSize',15)
	axis('square')
	axis([k0 N -.5 .5])
	set(gca,'XTick',[]);
	set(gca,'YTick',[]);
	title('angle','FontSize',16)
	hold on

end 

hold off

pause

figure(1)
clf

for k = k0:N
	
	subplot(121)
	
	plot([0 -l(k)*sin(theta(k))],[0 -l(k)*cos(theta(k))])
	hold on
	plot([0 -l(k)*sin(theta(k))],[0 -l(k)*cos(theta(k))],'.','MarkerSize',15)
	plot(-l(k)*sin(theta(k)),-l(k)*cos(theta(k)),'.','MarkerSize',45)
	plot([0 10-l(k)],[0 0])
 	plot([0 10-l(k)],[0 0],'.','MarkerSize',15)
	axis([-12 12 -16 8])
	set(gca,'XTick',[]);
	set(gca,'YTick',[]);
	hold off
	pause(P)
	
	subplot(122)

	plot(k,-theta(k),'.r','MarkerSize',15)
	axis('square')
	axis([k0 N -.5 .5])
	set(gca,'XTick',[]);
	set(gca,'YTick',[]);
	title('angle','FontSize',16)
	hold on
	
end

hold off
