I am writing a code for doing some integration. But I am stuck at some point(the last two lines). As it says Index Error: Index out of bounds. What I would like to do is- each time r has a value it should write to the empty corresponding index as an increment of 1 so that it can keep track of it. Any help would be appreciated. Here is the code-
from pylab import*
from math import*
dx = 981
dy = 1043
bx = 534.4
by = 109.5
index = zeros(shape=(1,dx+dy))
r=0
r_max=0
for i in xrange(1,dy+1):
for j in xrange (1,dx+1):
if i-by > 0:
theta = 180*atan(abs(j-bx)/(i-by))/pi
if theta<10:
r = round(sqrt((j-bx)**2+(i-by)**2))
if r>0:
index[r]+=1
from foo import *. It's better toimport fooand then callfoo.bar(). For example, I was thrown off byzeros()- where is it defined? You can't tell. If you doimport pylaband then callpylab.zeros(), it's much easier to understand what is happening.