There is error in the text related to this question thank you
CodePudding user response:
You could use an if statement to do this:
N = 20
matrix = numpy.zeros([3*N,N])
for j in range (N):
for i in range (2):
for i1 in range(i*N, (i 1)*N)):
if j <= 20:
beta = 0
elif j <= 40:
beta = 1
else:
beta = 5
matrix [i1,j] = numpy.array(readPlotFile['alpha'][beta,0,i1-i*N,j]
print(matrix)
Alternatively, it seems like you're trying to reshape an array, which could more efficiently be done directly using numpy operations. Check out the Numpy User Guide intro to reshape operations.
CodePudding user response:
You can do beta = [0] * 20 [1] * 20 [5] * 20