I have a loop for that generate a new vector (100,) in each iteration. So the code loop likes
for i in range (10):
for j in range (4):
#Create a new vector (100,)
#Concatenate 4 vector together to make (400,) #400=4*10
#Append the concatenation vectors (400,) in vertical to make (10,400) array
My expected is that generates a matrix size of (10,400) that concatenate vectors in these loops
Currently, my solution is
matrix_= np.empty([10,400])
for i in range (10):
vector_horz=[]
for j in range (4):
#Create a new vector (100,)
vector_rnd=#Random make a vector/list with size of (100,1)
#Concatenate 4 vector together to make (400,) #400=4*10
vector_horz.append(vector_rnd)
#Append the concatenation vectors (400,) in vertical to make (10,400) array
matrix_(:,i)=vector_horz
However, it said that my size of matrix and vector_horz cannot assign. Could you give me another solution?
numpyarrays. This involves repeated memory reallocation. Instead, declare the size of the array when you instantiate it, then fill it.