2

The below code is supposed to calculate some values and place them in incremental places in the numpy.zeros() array. The calculations all perform correctly but the array stays as just zeros. I could be missing something obvious so apologies if I am.

n = 256
lam = l

a = numpy.zeros([(len(z[0]) * len(z[:,0]) + n + 1), (n + len(z[0]))])
b = numpy.zeros([numpy.size(a, 0), 1])

#data fitting equations
k = 0
for i in range(len(z[0])):
    for j in range(len(z[:,0])-1):
        wij = smoother(z[j][i] + lam)
        a[k][(z[j][i]+lam)] = float(wij)
        print a[k][(z[j][i]+lam)]
        a[k][n+j] = float(-wij)

        b[k][0] = float(-wij * B[j])
        k = k + 1

Thanks, Tom

3
  • Could you post a full working example? It's hard to debug code if what we're given doesn't run. Commented Sep 7, 2013 at 2:21
  • 1
    Can't test it right now, bur replace all your indexing like a[i][j] with a[i, j] and I think you'll solve your issue. Commented Sep 7, 2013 at 3:28
  • Thanks Jaime that seems to have solved the problem. Commented Sep 7, 2013 at 15:34

1 Answer 1

1

Answer supplied by Jaime works fine. Use

a[1, 2] 

rather than

a[1][2]
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.