Sudip Das Sudip Das - 1 year ago 213
Python Question

How i will insert matrices in an array in python

Suppose I have 50 matrix(x1,x2...x50) of images of size 1028x1028. if I print the shape of any one among 50 matrix like this =>

print(x1.shape)


It will return (1028,1028).

I want to insert those matrices in an linear array(A) by using numpy or another else . when I Will
print(A.shape)
it will print (50,1028,1028).
How I will do this??

Answer Source

Ok, I feel strange for having to point that out, but

numpy.array([x1,x2,x3,...,x50]) 

will do that.

Also, it's a bad idea to have 50 separate variables x1, x2 and so on. Just put them into a list x and address them as x[0], x[1], and so on.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download