ในการรับไซน์ตรีโกณมิติของอาร์เรย์ของมุมที่กำหนดเป็นองศา ให้ใช้เมธอด numpy.sin() ในPython Numpy เมธอดจะคืนค่าไซน์ของแต่ละองค์ประกอบของพารามิเตอร์ตัวที่ 1 x นี่คือสเกลาริฟก็คือสเกลาร์ พารามิเตอร์ตัวที่ 1 x คือมุมในหน่วยเรเดียน (2pi หมายถึง 360 องศา) ที่นี่เป็นอาร์เรย์ของมุม พารามิเตอร์ที่ 2 และ 3 เป็นทางเลือก
พารามิเตอร์ตัวที่ 2 คือ ndarray ซึ่งเป็นตำแหน่งที่เก็บผลลัพธ์ หากมีให้ต้องมีรูปร่างที่อินพุตออกอากาศไป หากไม่ระบุหรือไม่มี ระบบจะส่งคืนอาร์เรย์ที่จัดสรรใหม่ Atuple (เป็นไปได้เฉพาะในฐานะอาร์กิวเมนต์ของคีย์เวิร์ด) ต้องมีความยาวเท่ากับจำนวนเอาต์พุต
พารามิเตอร์ที่ 3 คือเงื่อนไขที่ออกอากาศผ่านอินพุต ที่ตำแหน่งที่เงื่อนไขเป็น True อาร์เรย์ out จะถูกตั้งค่าเป็นผลลัพธ์ ufunc ที่อื่นอาร์เรย์ out จะคงค่าเดิมไว้ โปรดทราบว่าหากอาร์เรย์เอาต์ที่ยังไม่ได้กำหนดค่าเริ่มต้นถูกสร้างขึ้นโดยใช้ค่าดีฟอลต์ out=None ตำแหน่งภายในอาร์เรย์ที่มีเงื่อนไขเป็น "เท็จ" จะยังไม่ได้กำหนดค่าเริ่มต้น
ขั้นตอน
ขั้นแรก นำเข้าไลบรารีที่จำเป็น -
import numpy as np
ไซน์ตรีโกณมิติของอาร์เรย์ของมุม ค้นหา tan 0, tan 30, tan 45, tan 60, tan 90, tan 180 −
arr = np.array((0., 30., 45., 60., 90., 180.))
กำลังแสดงอาร์เรย์ของเรา -
print("Array...\n",arr) รับประเภทข้อมูล -
print("\nArray datatype...\n",arr.dtype)
รับขนาดของอาร์เรย์ -
print("\nArray Dimensions...\n",arr.ndim) รับจำนวนขององค์ประกอบของอาร์เรย์ -
print("\nNumber of elements in the Array...\n",arr.size)
หากต้องการค้นหาไซน์ของอาร์เรย์ของมุมที่กำหนดเป็นองศา ให้ใช้เมธอด numpy.sin() ใน Python Numpy -
print("\nResult...",np.sin(arr * np.pi / 180. )) ตัวอย่าง
import numpy as np
# To get the Trigonometric sines of an array of angles given in degrees, use the numpy.sin() method in Python Numpy
# The method returns the sine of each element of the 1st parameter x. This is a scalar if is a scalar.
print("The Trigonometric sines of an array of angles...")
# Array of angles
# finding tan 0, tan 30, tan 45, tan 60, tan 90, tan 180
arr = np.array((0., 30., 45., 60., 90., 180.))
# Display the array
print("Array...\n", arr)
# Get the type of the array
print("\nOur Array type...\n", arr.dtype)
# Get the dimensions of the Array
print("\nOur Array Dimensions...\n",arr.ndim)
# Get the number of elements in the Array
print("\nNumber of elements...\n", arr.size)
# To find sines of an array of angles given in degrees, use the numpy.sin() method in Python Numpy
print("\nResult...",np.sin(arr * np.pi / 180. )) ผลลัพธ์
The Trigonometric sines of an array of angles... Array... [ 0. 30. 45. 60. 90. 180.] Our Array type... float64 Our Array Dimensions... 1 Number of elements... 6 Result... [0.00000000e+00 5.00000000e-01 7.07106781e-01 8.66025404e-01 1.00000000e+00 1.22464680e-16]