Mon code ci-dessous ne remplit pas le tableau numpy/pylab appelé RRmeanArray. Quelqu'un peut-il me montrer comment corriger le code afin qu'il remplisse le tableau?problème de remplissage d'un tableau numérique
import pylab as p
RRmeanArray = p.array([])
startBeatIndex = 0
endBeatIndex = 10
for k in range(int(p.floor(len(QRSandRRarray[0])/10))-1):
print '++++++++++++++++++++++++++++++++++++++++++++'
print 'k is: ',k
print 'startBeatIndex is: ',startBeatIndex
print 'endBeatIndex is: ',endBeatIndex
print 'p.mean(QRSandRRarray[1,startBeatIndex:endBeatIndex]) is: ',p.mean(QRSandRRarray[1,startBeatIndex:endBeatIndex])
newMean = p.mean(QRSandRRarray[1,startBeatIndex:endBeatIndex])
print 'newMean is: ',newMean
RRmeanArray += [newMean]
print 'len(RRmeanArray) is: ',len(RRmeanArray)
startBeatIndex += 10
endBeatIndex += 10
print '++++++++++++++++++++++++++++++++++++++++++++'
Voici ce que je reçois en tant que sortie dans le shell python pour une itération typique de k:
++++++++++++++++++++++++++++++++++++++++++++
k is: 619
startBeatIndex is: 6190
endBeatIndex is: 6200
p.mean(QRSandRRarray[1,startBeatIndex:endBeatIndex]) is: 0.5971
newMean is: 0.5971
len(RRmeanArray) is: 0
++++++++++++++++++++++++++++++++++++++++++++
EDIT: Merci , Thomas. Vous l'avez presque compris. La version de travail est:
RRmeanArray = p.zeros(len(range(int(p.floor(len(QRSandRRarray[0])/10))-1)))
startBeatIndex = 0
endBeatIndex = 10
for i,k in enumerate(range(int(p.floor(len(QRSandRRarray[0])/10))-1)):
newMean = p.mean(QRSandRRarray[1,startBeatIndex:endBeatIndex])
RRmeanArray[i] += [newMean]
startBeatIndex += 10
endBeatIndex += 10
Cette question a maintenant réponse.
Si vous êtes le même que l'autre MedicalMath, vous devez utiliser ce compte. – Thomas
Est-ce que cela fait vraiment ce que vous voulez? Je suis confus par cette ligne: RRmeanArray [i] + = [newMean] – Thomas