Demos
 Demos
Source Code of corr.num Document
Document 
 
` Correlation between noisy signals

x = 0..2*pi len 128      ` a single cycle
noise = 0.2..0.2 len 128 ` amplitude of noise
randomize
n1 = sin(x)+rand(noise)   ` first noise signal
n2 = sin(2*x)+rand(noise) ` second noise signal
ss1 = 0.25*cos(x^2)     ` first source signal
ss2 = 0.25*cos(2.5*x^2) ` second source signal
s1 = ss1+n1 ` first measured signal
s2 = ss1+n2 ` second measured signal
s3 = ss2+n1 ` third measured signal

` correlation without filtering

func corr(y1,y2)
   ft1 = fft(y1)
 ft2 = fft(y2)
 return real(ifft(ft1*conj(ft2)))

` correlation with filtering

func corrf(y1,y2)
   i = 2,3,127,128 ` low freq. components
 ft1 = fft(y1)
 ft1[i] = 0 ` filter out
 ft2 = fft(y2)
 ft2[i] = 0 ` filter out
 return real(ifft(ft1*conj(ft2)))

` compute the correlations
` (to display the correlations around zero we must
` shift the arrays after the computation)

` correlations without low-pass filter
corr12 = shifft(corr(s1,s2))
corr13 = shifft(corr(s1,s3))

` correlations with low-pass filter

corrf12 = shifft(corrf(s1,s2))
corrf13 = shifft(corrf(s1,s3))

xx = x-pi ` -pi to pi; used in the graphs
 
 Demos
Demos
Copyright © 2004 KEDMI Scientific Computing. All Rights Reserved. Document 
Document