The correlation can be used to measure the degree at which both signals are related. One example can be used to understand its action. In the chapter `Plotting a vector or some part of a vector' we generated something similar to an EEG segment by using two sinusoids near in frequency
-->t = 0:.01:10; -->signalbase = sin(2 * %pi * 9.7 * t) + sin(2 * %pi * 10.3 * t);With the previous code we simulated 10 seconds of signal sampled at 100 Hz. The signal (contained in `signalbase') is modulated in amplitude by adding two sinusoids near in frequency. Now we are going to create a Gaussian noise (contained in `noise') of the same length. Since it contains all the frequencies, it is called `white noise' by analogy with `white light'. When we use `rand' having previously called the option `normal' we get a distribution of values whose mean is '0' and whose standard deviation is '1'. Since we multiply by `2' we get a normal distribution of values with a mean of `0' and a standard deviation of `2'.
-->rand('normal')
-->rand('seed',0)
-->noise = 2 * rand(signalbase);
-->signalnoise = signalbase + noise;
Now we are going to study the correlation of the `EEG' and of the `noise'. We begin with the `EEG'.
-->xbasc() -->corrsignalbase = corr (signalbase,1000); -->xsetech([0,0,1,1/2]) -->plot2d(t(1:500),signalbase(1:500)); -->xsetech([0,1/2,1,1/2]) -->plot2d(t(1:500),corrsignalbase(1:500))
![]() |
We can see autocorrelation as a way to detect periodicity in signals. The following code represents only a few values to improve the resolution.
-->xbasc() -->corrsignalbase = corr (signalbase,1000); -->xsetech([0,0,1,1/2]) -->plot2d(t(1:50),signalbase(1:50)); -->xsetech([0,1/2,1,1/2]) -->plot2d(t(1:50),corrsignalbase(1:50))
![]() |