Analysis: Signal Processing: Correlation
Compute correlation of two signals
1. corr1 ix1:=Col(1) ix2:=Col(2);
2. corr1 ix1:=Col(1) ix2:=Col(2) type:=circular;
3. corr1 ix1:=Col(1) ix2:=Col(2) norm:=1;
4. corr1 ix1:=Col(1) ix2:=Col(2) type:=circular norm:=1 oy:=(col(3),col(4));
Please refer to the page for additional option switches when accessing the x-function from script
Display Name |
Variable Name |
I/O and Type |
Default Value |
Description |
---|---|---|---|---|
Input | ix1 |
Input vector |
|
Specifies the first input signal. |
Input | ix2 |
Input vector |
|
Specifies the second input signal. If you would like to calculate auto-correlation, this should be the same as Input Signal 1. |
Sampling Interval | interval |
Input double |
|
Specifies the sampling interval. The default is <auto>, which corresponds to an automatically-computed interval. |
Type | type |
Input int |
|
Specifies whether to compute a linear correlation or a circular correlation. Option list
|
Normalize | norm |
Input int |
|
Specifies whether the result should be normalized |
Output | oy |
Output XYRange |
|
Specifies the output range See the syntax here. |
corr1 ix1:=col(1) ix2:=col(1)
corr1 -t "my correlation theme.oth"
// Use correlation to detect time delay between two signals //Create a workbook and import the sample data newbook sheet:=0 name:=Correlation; newsheet xy:="YYYXY" labels:="Signal 1|Signal 2|Shifted Signal 2"; fname$ = System.path.program$ +"Samples\Signal Processing\Correlation.dat"; impasc; string bkname$ = %H; // save the book name as plotting will create new window to change %H //Calcualte correlation corr1 ix1:=1 ix2:=2 type:=line oy:=(4,5); //Get the maximum correlation and calculate the time difference stats ix:=5 max:=maxcorr; shift=col(4)[list(maxcorr, col(5))] + 1; //Shift Signal 2 and plot copydata irng:=col(2) orng:=col(3)[shift]; %a=nameof(col(3))$; plotxy iy:=1 plot:=200 ogl:=Layer1; plotxy iy:=[bkname$]1!col(3) plot:=200 ogl:=Layer1; set %a -c 3;
For more information, please refer to our User Guide.
Keywords:linear, circular