How to make the matrix include variable "x"
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. --- Kazuhiko UEBAYASHI u_kazu(a)nifty.com
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@ucsd.edu "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter
On May 2, 2005 12:39 am, 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'm not sure what you're trying to do here, but it doesn't seem relevant for what you do below.
I tried in Python with SciPy
from scipy import *
x0 = 10; x1 = 8; x2 = 3 print mat('[x0; x1; x2]')
You probably meant to do: print mat([x0, x1, x2]) Your first error was putting the quotes '...' and your second error was the semicolons. I think that comes from a column vector notation in matlab but I'm not sure.
Matrix([[0], [1], [2]]) . I expected the answer Matrix([[10], [8], [3]]) but it didn't work well.
I get the following In [1]: from scipy import * In [2]: x0=10;x1=8;x2=3; In [3]: print mat([x0,x1,x2]) Matrix([ [10, 8, 3]]) (ugly formatting on the Matrix object there!!!) David
Hi. Thank you very much for your replys. Robert Kern wrote:
When mat() is interpreting a string, it doesn't evaluate variables.
I'm newbie about python & scipy. How did you know this point? Could you tell me a reference site? David Grant wrote:
it doesn't seem relevant for what you do below.
Absolutely. I was confused what I wanted to say. (& I'm not good at English) Now I can make the variable Matrix. (3x1 matrix = colum vector; 1x3 matrix = row vector). Then next I'm going to make the N x N matrix from Nth sets of 1xN matirix. Is it possible? Thanks. -- Kazuhiko UEBAYASHI mailto:u_kazu(a)nifty.com
participants (4)
-
David Grant -
Kazuhiko UEBAYASHI -
Kazuhiko UEBAYASHI / 上林 一 彦 -
Robert Kern