我对for循环中的某些if语句有疑问。这是我的代码:
import numpy as np
mv = []
mb = []
mbv = []
M = []
for i in range (0,25):
mv.append(10.1 - 2.5 * np.log10(fv[i]/1220000))
mb.append(11.0 - 2.5 * np.log10(fb[i]/339368))
mbv.append(mb[i]-mv[i])
if ( 0.00 < mbv[i] < 0.05):
M.append(1.1)
if ( 0.05 < mbv[i] < 0.1):
M.append(1.8)
if ( 0.1 < mbv[i] < 0.2):
M.append(2.2)
else:
M.append(0)
print i+1, mbv[i], M[i]
这就是我得到的结果:
1 0.117517744922 2.2
2 0.105291760392 2.2
3 0.0414704330434 1.1
4 0.709631736921 0
5 0.0634562921955 0
6 0.9 1.8
7 0.123732441181 0
8 0.332213182737 0
9 0.0783116509167 2.2
10 0.109696428387 0
11 0.812457966075 1.8
12 0.0796972381532 0
13 0.0933833026562 2.2
14 0.0448112197058 0
15 0.107871295045 1.8
16 0.072180255058 0
17 0.134980217798 1.8
18 0.453454266409 0
19 0.0498332192697 1.1
20 0.141914194517 0
21 0.0712870748016 2.2
22 0.622521992135 1.8
23 0.176515236738 0
24 0.607814524935 2.2
25 0.0521329729172 0
0
如您所见,数字5的mbv为0.0634,因此M值应为1.8,但其值为0。
郎朗坤
qq_遁去的一_1
相关分类