May-07-2018, 10:23 AM
Hello Python forum
I am trying create a 2D out that is the cross correlation between y-z planes
![[Image: solSgIF.png]](https://i.imgur.com/solSgIF.png)
I wrote this code, which doesn't work
Or if you think there is a better way/easier way I would appreciate that too.
BR Mark
I am trying create a 2D out that is the cross correlation between y-z planes
![[Image: solSgIF.png]](https://i.imgur.com/solSgIF.png)
I wrote this code, which doesn't work
import numpy as np
from scipy import signal
import scipy as ssc
np.random.seed(0)
data=np.random.rand(32,32,8192)
#z, y, x = data[:,0,0],data[0,:,0],data[0,0,:]
z=data[:,0,:]
y=data[0,:,:]
Cyz=np.ones((32,32))
Cyz1=np.ones((32,32)) #allocating matrix
for i in range(32):
Cyz[i,i] = np.corrcoef(y[i,i],z[i,i]) # cross correlation
for i in range(32):
Cyz1[i,i] =ssc.signal.correlate2d(y[i,i],z[i,i]) If you are familiar with any of these two functions, please, could you tell me what I am doing wrong? Or if you think there is a better way/easier way I would appreciate that too.
Error:Traceback (most recent call last):
File "<ipython-input-33-dd850ca77ad0>", line 2, in <module>
Cyz[i,i] = np.corrcoef(y[i,i],z[i,i]) # cross correlation
ValueError: setting an array element with a sequence.Thank you! BR Mark
