vendredi 29 mai 2015

Splitted Array being filled in for loop by function calculating values from a splitted array

I got stuck at a for loop Problem.

I have a signal as an array and I split it up in multiple epochs.

times = np.arange(0, duration, 1 / sfreq)
nse1 = np.random.rand(times.size) * nse_amp
x =  amp * np.sin( 2 * np.pi * 200 * times            ) + nse1
x2 = np.array_split(x,epochs)

I do this a second time for a y-signal. Let's say my signal x has the shape of (100) then my splitted array for 2 epochs should have the form of (2, 50).

Now I want to use a function in a for loop to calculate a value for each value of each segment of my split up array...Something like:

for i in range(0,epochs):
    Rxy[i], freqs_xy[i] = mlab.csd(x2[i], y2[i], NFFT=nfft, Fs=sfreq)

So I will get an array for Rxy like (2, 50)

Hope you get what I want to do.

Greetings, Daniel

Aucun commentaire:

Enregistrer un commentaire