% exploring the resolution of the spectral coherency analysis
clear all;

t=0:300; 

figure(1);

for i=1:10
    
r1=rand(size(t));

r1=r1+(.1*sin(2*pi*t/12))+(.2*sin(2*pi*t/9))+(.1*sin(2*pi*t/7));

r2=rand(size(t));

r2=r2+(.2*sin(2*pi*t/9));

mscohere(r1,r2);
hold on;
end
hold off;

% puts period for coherence analysis at part marked by mouse click
set(gcf,'WindowButtonDownfcn',[...
	'p=get(gca,''CurrentPoint'');',...
	'x=num2str(2/p(1,1),4);',...
	'y=int2str(1/p(1,2));',...
	'space=0;',...
	'disp(p(1,1));',...
	'text(p(1,1),p(1,2)+space,x,',...
			'''HorizontalAlignment'',''center'',',...
			'''FontSize'',12,''Color'',''k'')'])