Get a value from a numpy matrix

Question:

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.

Asked By: Lee

||

Answers:

>>> 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)
Answered By: jamylak
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.