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

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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])