Q:

Write a NumPy program to convert cartesian coordinates to polar coordinates of a random 10x2 matrix representing cartesian coordinates

0

Write a NumPy program to convert cartesian coordinates to polar coordinates of a random 10x2 matrix representing cartesian coordinates.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import numpy as np
z= np.random.random((10,2))
x,y = z[:,0], z[:,1]
r = np.sqrt(x**2+y**2)
t = np.arctan2(y,x)
print(r)
print(t)

Sample Output:

[ 0.46197382  0.07034582  0.89015703  1.06227375  1.29780158  0.32823362                                                                      
  0.99823096  0.74005334  0.38023205  0.62537423]                      
[ 1.05405564  1.09799508  0.75642993  0.97273388  0.86502465  0.88995172                                                                      
  0.3019899   1.05539822  0.91697477  1.22828465]

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now