Write a NumPy program to convert cartesian coordinates to polar coordinates of a random 10x2 matrix representing cartesian coordinates.
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]
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer