2 May 2005 09:55
Re: How to make the matrix include variable "x"
Robert Kern <rkern <at> ucsd.edu>
2005-05-02 07:55:20 GMT
2005-05-02 07:55:20 GMT
Kazuhiko UEBAYASHI wrote:
> I'm trying to use SciPy module.
>
> Is it possble to make the following Matrix using SciPy ?
>
> A(x) = (x**0 x**1 x**2 ).
>
>
> I tried in Python with SciPy
> >> from scipy import *
> >> x0 = 10; x1 = 8; x2 = 3
> >> print mat('[x0; x1; x2]')
> Matrix([[0],
> [1],
> [2]])
> . I expected the answer
> Matrix([[10],
> [8],
> [3]])
> but it didn't work well.
When mat() is interpreting a string, it doesn't evaluate variables. In
this case, it's ignoring the 'x' characters.
You want
mat([[x0], [x1], [x2]])
--
--
Robert Kern
rkern <at> ucsd.edu
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
RSS Feed