我想写一个有两个变量x
和D
的函数,其中每个变量都是一个函数。(我将它们作为数组放入下面的代码中作为测试)。你知道吗
我想要的是多次运行这个函数,每次我使用一组x
和D
的值来获得Sec_nucli
,然后一次又一次地将结果Sec_nucli
用作新的输入。你知道吗
我试过这个:
x = np.array([16.7, 16.5, 16.1, 15, 13.5,14.2, 14.9, 13.7]) # an example
D = np.array([0, 1, 4, 7, 16, 31, 64, 127]) # example
n_H = 0.9
Sec_nucli = []
x = []
D = []
for i in range(1, n):
Sec_nucli[i] = n_H * D * xsec[i]
sec_nucli += sec_nucli[i]
return sec_nucli
## I defined the function like this:
def Fragmentation():
n_H = 0.9
Sec_nucli[i]= n_H *D* x[i]
return Sec_nucli
Sec_nucli = 0 def Fragmentation(D,x): s_nucli = n_H * D * x return s_nucli for xi in x: for Dj in D: print(xi, Dj) Sec_nucli += Fragmentation(xi,Dj) print(Sec_nucli)
;相关问题 更多 >
编程相关推荐