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.

27 lines
938 B

import numpy as np
def x1_2(problemIndex): # 程序给出任一函数 y=f(x)计算x=1到1000的y值赋值给xyMap
# shape = [1000,2] #x值为1到1000y为其对应函数值
xyMap = np.random.rand(1000, 2)
if problemIndex == 1:
for x in range(1, 1001):
xyMap[x - 1][0] = x # xyMap序号为0-999
xyMap[x - 1][1] = np.sin(x)
return xyMap
elif problemIndex == 2:
for x in range(1, 1001):
xyMap[x - 1][0] = x
xyMap[x - 1][1] = np.cos(x)
return xyMap
elif problemIndex == 3:
for x in range(1, 1001):
xyMap[x - 1][0] = x
xyMap[x - 1][1] = np.tan(x)
return xyMap
elif problemIndex == 4:
for x in range(1, 1001):
xyMap[x - 1][0] = x
xyMap[x - 1][1] = x * 2 + 2
return xyMap
if __name__ == '__main__':
print(x1_2(4)[:50])