index 0 is out of bounds for axis 0 with size 0

0

I have imported all the necessary libraries, I want to pass it to FFT and this is my code (I have already declared the fixes and put the address where you will extract everything from):

#k=f12.size+f24.size
k=(f12.size+f24.size)*100
tp1,tp2,tp3,tp4,tp5=np.zeros(k),np.zeros(k),np.zeros(k),np.zeros(k),np.zeros(k)
ytot=np.zeros(k)

cnt=0
for b in range(0,2):
    if b==0:
        n=f12.size
        y1224=y12
    else:
        n=f24.size
        y1224=y24
    for a in range (0,n): 
        file = str(f12[a])
        if int(file)>99:
            matdata = scipy.io.loadmat(direc+file+'.mat')
            DE = np.array(matdata['X'+file+'_DE_time']).T
        else:            
            matdata = scipy.io.loadmat(direc+file+'.mat')
            DE = np.array(matdata['X0'+file+'_DE_time']).T


        x = np.fft.fft(DE)
        Nd = DE.size
        x2 = 2.0/Nd*np.abs(x[1:Nd//2])

        Tm=1024 # Establecer el tamaño de la muestra de cada señal
        #Nm=DE.size//Tm # Numero de muestras
        #Nm=100 # Valor establecido por caso de ejemplo
        N=Tm

        Ini=0
        Fin=Tm

        for c in range (0,Tm):

            F_DE=x2[0, Ini:Fin]

            tp1[cnt]=F_DE.mean()
            tp2[cnt]=np.sum(np.absolute(F_DE))/N
            tp3[cnt]=np.sum(np.power(np.absolute(F_DE-tp2[a]), 2))/(N-1)
            tp4[cnt]=np.sum(np.power(np.absolute(F_DE-tp2[a]), 3))/(N*(np.power(tp3[a],3/2)))
            tp5[cnt]=np.sum(np.power(np.absolute(F_DE-tp2[a]), 4))/(N*(np.power(tp3[a],2)))


            ytot[cnt]=y1224[a]

            cnt=cnt+1
            Ini=Ini+Tm
            Fin=Fin+Tm
tp1 = np.asmatrix(tp1)
tp2 = np.asmatrix(tp2)
tp3 = np.asmatrix(tp3)
tp4 = np.asmatrix(tp4)
tp5 = np.asmatrix(tp5)

ytot = np.asmatrix(ytot)

And I get the following error:

IndexError                                Traceback (most recent call last) <ipython-input-22-5bd17573a3b8> in <module>()
     36         for c in range (0,Tm):
     37 
---> 38             F_DE=x2[0, Ini:Fin]
     39 
     40             tp1[cnt]=F_DE.mean()

IndexError: index 0 is out of bounds for axis 0 with size 0

I hope you can help me.

    
asked by Diego Steven Ochoa Rivas 08.12.2018 в 22:57
source

0 answers