%demonstrating coherence between different records using the multi-taper method % %Two time-series are generated and you are asked to guesse whether they are %coherent or incoherent. Coherent and incoherent time-series are generated %at random. % %Methods 2 through 4 are incoherent, while 1 and 5 produce coherent time-series. figure(1); clf; hold on; N=100; for ct=1:100; choose=round(rand*5+0.5); if choose==2 | choose==3, x=detrend(normPH(cumsum(randn(N,1)))); y=detrend(normPH(cumsum(randn(N,1)))); end; if choose==4, x=normPH(conv([1 -1 1 1],randn(N,1))); y=normPH(conv([1 -1 1 1],randn(N,1))); end; if choose==1, x=randn(N,1); y=conv([-1 -3 -3 2 1 0.5],x); y=y(3:end-3); end; if choose==5, x=randn(N,1); y=conv([-1 -3 -3 2 1 0.5],x); y=y(3:end-3); x=cumsum(x); end; figure(1); clf; hold on; plot(x,'k'); plot(y,'r'); axis tight; h=ylabel('realization'); font(h,16); h=xlabel('time'); font(h,16); font(gca,16); pause; figure(2); clf; hold on; nw=4; cmtm(x,y,1,nw,0,0,1); subplot(211); if (choose==1 | choose==5), h=text(1/80,0.85,'Coherent'); font(h,42); else; h=text(1/80,0.85,'Incoherent'); font(h,42); end; pause; end;