简体   繁体   中英

Get a value from a numpy matrix

If I have a numpy matrix:

>>> S
matrix([[ 0.66581073+0.00033919j],
        [ 0.81568896-0.03291265j],
        [ 0.99884785+0.00045446j]])

How do I get an element, without the matrix wrapper?

If I try:

>>> S[0]

I get:

matrix([[ 0.66581073+0.00033919j]])   

whereas what I want is:

0.66581073+0.00033919j

I have had a look at the documentation and can't find a function/operator to do this.

>>> import numpy as np
>>> I = np.matrix([[ 0.66581073+0.00033919j],
        [ 0.81568896-0.03291265j],
        [ 0.99884785+0.00045446j]])
>>> 
>>> I[0, 0]
(0.66581073000000002+0.00033919000000000001j)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM