I looks like you skip the first datapoint since you write x = data[1:len(data),0]
and so forth. As @trincot mentioned, you also have to care about the y[i-1]
case for i=0
. Maybe the following will help you:
tst = []
x = data[:,0]
y = data[:,1]
intt = data[:,2]
for i in range(1,len(data)):
if intt[i]!=0:
tst.append((x[i]**2.0+ y[i]-y[i-1])**2.0)
else:
break
This includes all data points in x
, y
, and intt
, but the first data point will still be skipped since the loop starts with i=1
.