Reputation: 21
I am trying to get matrix T in python and don't know what my mistake is. This is my code:
c=dx/L
s=dy/L
cc=c**2
ss=s**2
cs=c*s
T = np.matrix( ((cc, cs,-cc,-cs),
(cs, ss,-cs,-ss),
(-cc,-cs, cc, cs),
(-cs,-ss, cs, ss))
The values that are given are dx, dy and L. If I want to run the script it just says:
"..../miniconda3/envs/myenv/lib/python3.6/site-packages/numpy/matrixlib/defmatrix.py", line 240, in __new__
raise ValueError("matrix must be 2-dimensional")
ValueError: matrix must be 2-dimensional
Can anyone of you help me? I have no idea why the matrix should not be 2-dimensional. Thanks
Upvotes: 2
Views: 72
Reputation: 402
Try to make T as an array:
T = np.array( ((cc, cs,-cc,-cs),
(cs, ss,-cs,-ss),
(-cc,-cs, cc, cs),
(-cs,-ss, cs, ss)) )
Matrixes in numpy module are only 2-dimensional, but arrays are N-dimensional.
Upvotes: 1