分段进程在python中起作用

2024-04-24 19:54:02 发布

您现在位置:Python中文网/ 问答频道 /正文

我想写一个有两个变量xD的函数,其中每个变量都是一个函数。(我将它们作为数组放入下面的代码中作为测试)。你知道吗

我想要的是多次运行这个函数,每次我使用一组xD的值来获得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

Tags: 函数代码inanforreturnexamplenp
1条回答
网友
1楼 · 发布于 2024-04-24 19:54:02

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)

相关问题 更多 >