Demos
 Demos
Output Document of corr.num Code
Code 
 
Correlation Of Noisy Signals

When we measure signals in a noisy environment and calculate correlations between the measured signals we must take into account the noise that we have in the system. In the following demonstration we measure three signals in a noisy environment. The noise consists of a low frequency sine wave with an additional small random noise. We define two noise signals, n1, and n2, where n2 has twice the frequency of n1. Figure 1 shows these signals:
Figure 1. The noise signals.
The signals that we want to measure are chirp waves, ss1, ss2, where ss2 has a larger frequency modulation. These are shown in Fig. 2.
Figure 2. The source signals.
We make three measurements. The first, s1, is ss1 measured in the presence of noise n1; the second, s2, is the same ss1 measured in the presence of noise n2; and the third s3, is ss2 measured in the presence of noise n1. These signals are shown in Fig. 3:
Figure 3. The measured signals.
In order to compare the measured signals we calculate the cross-correlation of s1 with s2 and with s3. These correlations are shown in Fig. 4. Looking at the results we see that s1 and s3 have a good correlation while the correlation between s1 and s2 is much smaller.
Figure 4. Correlations without filtering.
So, by just measuring the signals and calculating the correlations we conclude that it is more likely that the first and the third measured signals were originated from the same source signal while the second measured signal was originated from another signal - which is wrong, of course.
To get the right answer we must use our knowledge about the low frequency noise in the system. So, before calculating the correlations, we have to remove the low frequency components from the measured signals. When we do so, we get the following correlations:
Figure 5. Correlations with filtering.
Now we see that s1 and s2 have a good correlation, while s3 is different.

Looking at the function corrf, which applies the low-pass filter while calculating the correlation, we see that we had to filter out only the first two low frequency components in the spectrum of each signal, namely, elements 2 and 128 which represent the first harmonic, and elements 3 and 127 which represent the second harmonic.
 
 
 Demos
Demos
Copyright © 2004 KEDMI Scientific Computing. All Rights Reserved. Code 
Code