1

I am trying to create a 3D array with numpy with dimensions [282][282][256]. I have tried

np.zeros((282,282,256))

but this is not giving me the correct width and height. How do I create such an array that has 282 width and height, and each cell is an array of 256 elements?

1
  • Your instruction seems correct. Print the shape of your array and tell us what shape you were expecting. Commented Apr 9, 2018 at 12:52

1 Answer 1

2

your are doing it right

var = np.zeros((282,282,256),dtype=float)

but you will access the elements of array as below:

var[1,1,2] = 10
var[0,0,3] = 5
Sign up to request clarification or add additional context in comments.

2 Comments

if I type var[1,1,2], I am accessing 1st row 1st column, and the 2nd element in that cell's array ?
array indexing starts at 0, so you are accessing 2nd row, 2nd col and 3rd element

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.