Reputation: 819
Say if I have a column matrix
n =
[[0.649100404993098]
[0.548818798116734]
[-0.526750976336541]]
I want to assign the values of n to x,y and z. For example x= 0.649100404993098, y=0.548818798116734, z=-0.526750976336541
. If I do x,y,z =n
, then they are assigned as a list with desired values. How can I directly assign the values to x,y and z? Thanks:)
PS: The code I'm running is
b= 9.166801286935154 ,c= 7.750592706723353 ,d= -7.438943945547988
sig = np.matrix([[b],[c],[d]])
n = np.dot(1/sqrt(b**2+c**2+d**2),sig)
nx, ny, nz = [i for i in n]
Upvotes: 1
Views: 44
Reputation: 1742
You can try this if you're sure that the length of each element is 1:
nx, ny, nz = [i.item() for i in n]
Upvotes: 1
Reputation: 340
You can get it with:
x, y, z = [i[0] for i in n]
If you have more than one column you could make it i[j]
where j is the column index.
Upvotes: 1