You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
import numpy as np
|
|
|
|
|
import math
|
|
|
|
|
|
|
|
|
|
def x1_3(problemIndex): # 程序给出任一函数y=f(x)计算x=-500到+500的y值赋值给xyMap
|
|
|
|
|
c = 0 # 此处x赋值为-500到-1到,1到500到1000个
|
|
|
|
|
shape = [1000, 2] # y赋值为其对应的函数
|
|
|
|
|
xyMap = np.random.rand(1000, 2)
|
|
|
|
|
if problemIndex == 1:
|
|
|
|
|
for x in range(-500, 500):
|
|
|
|
|
if (x == 0):
|
|
|
|
|
continue
|
|
|
|
|
xyMap[c][0] = x
|
|
|
|
|
xyMap[c][1] = math.sin(x)
|
|
|
|
|
c += 1
|
|
|
|
|
return xyMap
|
|
|
|
|
elif problemIndex == 2:
|
|
|
|
|
for x in range(-500, 500):
|
|
|
|
|
if (x == 0):
|
|
|
|
|
continue
|
|
|
|
|
xyMap[c][0] = x
|
|
|
|
|
xyMap[c][1] = math.cos(x)
|
|
|
|
|
c += 1
|
|
|
|
|
return xyMap
|
|
|
|
|
elif problemIndex == 3:
|
|
|
|
|
for x in range(-500, 500):
|
|
|
|
|
if (x == 0):
|
|
|
|
|
continue
|
|
|
|
|
xyMap[c][0] = x
|
|
|
|
|
xyMap[c][1] = math.tan(x)
|
|
|
|
|
c += 1
|
|
|
|
|
return xyMap
|
|
|
|
|
elif problemIndex == 4:
|
|
|
|
|
for x in range(-500, 501):
|
|
|
|
|
if (x == 0):
|
|
|
|
|
continue
|
|
|
|
|
xyMap[c][0] = x
|
|
|
|
|
xyMap[c][1] = x * 2 + 2
|
|
|
|
|
c += 1
|
|
|
|
|
return xyMap
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
print(x1_3(1))
|