Compute the Cross-correlation coefficient out of one Vector
    2 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Jacob Shamir
 el 15 de Ag. de 2020
  
    
    
    
    
    Comentada: Jacob Shamir
 el 22 de Ag. de 2020
            Hello everyone,
I got one vector with 100000 random numbers (100000X1) that each value is at a different time - representing a random process.
I need to calculate the Cross-correlation coefficient without using the "corr" function between the original process and the time-transmitted procedures, 0 to 15-time shifts. (Between x [t] and x [t + k], k = 0,1, ... 15).
I was thinking of using a for loop to make 14 more different Vectors and make them all one matrix and then calculate the Cross-correlation coefficient.
but I don't know to make those 14 different vectors, also - I don't know if that is the right way to do it.
Thank you.
0 comentarios
Respuesta aceptada
  Alan Stevens
      
      
 el 15 de Ag. de 2020
        If your data is in a vector V, then the following should do it:
coeff = zeros(1,16);
for k = 1:16
    lag = k-1;
    v1 = V(1:end-lag);  
    v2 = V(k:end);
    v1scaled = (v1 - mean(v1))/std(v1);
    v2scaled = (v2 - mean(v2))/std(v2);
    coeff(k) = v1scaled'*v2scaled/(n-1);
end
Más respuestas (0)
Ver también
Categorías
				Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!