My main aim is to print out the values of one variable which is in a double for loop and under an if-statementbut however I tend to get an error IndexError: invalid index to scalar variable. Here is my codes
import numpy as np
nR = 133
nP = 255
Pmin = 0.09
Pmax = 20.0
dTime = 0.005
g = np.zeros((nR+1, nP+1), dtype=np.float64)
E01 = np.zeros(nR+1)
n = nR - 1
l = nP - 1
LnPmax = np.log(Pmax)
LnPmin = np.log(Pmin)
dLnP = (LnPmax - LnPmin)/(l-1)
odt = 1/dTime
for i in range(1, n):
T1 = E01[i]*dTime
for k in range(1, l):
LnPa = T1 + LnP[k]
ka = int((LnPa - LnPmin)/dLnP + 1)
if LnPa <= LnPmin:
ha = 0.0
elif LnPa >= LnPmax:
ha = 0.0
else:
ha = g[i][ka] + (g[i][ka+1] - g[i][ka])*(LnPa - LnPa[ka])/dLnP
print ha
whenever i try to print ha I get an error IndexError: invalid index to scalar variable, I have looked up to other solution on stackoverflow and google but it was to no avail perhaps anyone could help me, I will appreciate :)
Aucun commentaire:
Enregistrer un commentaire