嵌套列表和lis的For循环操作

2024-09-23 06:29:21 发布

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

G = [100,200,300]
I_cel = [[0.1, 0.2,0.3,0.4],[1,2,3,4],[11, 22,33,44]]
for i in list(range(len(G))):
    V_cel.append([])
    Iph_g = Iph_cal[i]  
    Icel_g = I_cel[i]
    for j in Icel_g:    
        a = math.log((Iph_g - j - I_sat)/I_sat,10) - j*R_se  
        V_cel[i].append(a)
print(V_cel[0])

**输出为:
ValueError: math domain error输出中的箭头指向a = math.log((Iph_g - j - I_sat)/I_sat,10) - j*R_se。看起来这是一些数学错误的根源。一些帮助。当我设置a = i*j(检查整个程序)并成功执行代码时,其他的一切都是循环


Tags: inlogforlenrangemathsatlist
1条回答
网友
1楼 · 发布于 2024-09-23 06:29:21
I_cel = [[0.1, 0.2,0.3,0.4],[1,2,3,4][11, 22,33,44]]

我想你漏掉了一个逗号

您得到一个数学域错误,因为在math.log(j,10)上求值时j等于0。 也许你想用数组值而不是它的索引做些什么

而且,我不知道G的值是什么。它们是否用于设置V_cel的长度

相关问题 更多 >