% Goes with the program distributed_synch.m
function dzdt=distributed_sych_func(t,z);

global N K omega

theta=z;

dthetadt=theta; % Just force to be a column

for i=1:N
	summ=0;
	for j=1:N % Create the sum for each oscillator that links the oscillators
		difftheta=theta(j)-theta(i); 
		summ=summ+sin(difftheta);
	end
	
	dthetadt(i)=omega(i)+(K/N)*summ; 
end


dzdt=dthetadt;

% End
