Write a NumPy program to convert cartesian coordinates to polar coordinates of a random 10x2 matrix representing cartesian coordinates
- برمجة بايثون
- 2021-09-13
- mhanasmh00489829403
الأجوبة
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]
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال