1

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]

2 Answers 2

1

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]
Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.