Transform vectors into an array

0

I have several signals, where s1, s2 to sn, are vectors of size n, I would like to join them in an array to look like this:

matriz = ( [s1]
           [s2]
           ...
           [sn] )

So that I can access an element at any point, for example, [4] [433], the value of row position 4 and column 433.

I tried approaches with np.vstack () , but np.vstack () really does the proposed? Or did I travel?

    
asked by anonymous 11.05.2018 / 21:12

1 answer

3

There is no mystery:

matrix = [ [  1,  2,  3,  4,  5 ],
           [  6,  7,  8,  9, 10 ],
           [ 11, 12, 13, 14, 15 ],
           [ 16, 17, 18, 19, 20 ] ]

print( matrix[2][3] )

Alternatively, you can use the append() method:

matrix = []

matrix.append( [  1,  2,  3,  4,  5 ] )
matrix.append( [  6,  7,  8,  9, 10 ] )
matrix.append( [ 11, 12, 13, 14, 15 ] )
matrix.append( [ 16, 17, 18, 19, 20 ] )

print( matrix[2][3] )
    
11.05.2018 / 22:21