Python 矩阵中 求每行个别列的norm值,然后再求所有行的norm总和
taux_with_orthese=[]withopen('tau_mannequin_1432139027.txt')asf:forlineinf.readlines(...
taux_with_orthese=[]
with open('tau_mannequin_1432139027.txt') as f:
for line in f.readlines():
taux_with_orthese.append(map(float,line.replace("\n","").split(",")))
taux_with_orthese = np.array(taux_with_orthese)
tau_norm_instant = []
print tau_norm_instant
for i in range(0,len(taux_with_orthese)-1):
tau_norm_instant = np.array([np.sqrt((taux_with_orthese[i][28])**2 + (taux_with_orthese[i][29])**2 +(taux_with_orthese[i][30])**2 + (taux_with_orthese[i][31])**2 + (taux_with_orthese[i][32])**2 + (taux_with_orthese[i][33])**2+
(taux_with_orthese[i][34])**2)])
print tau_norm_instant
程序这么写完之后 只出现一列数
,我想求这一列数的和 怎么求呢?试过 tau_norm_instant = sum(
np.array([np.sqrt((taux_with_orthese[i][28])**2 + (taux_with_orthese[i][29])**2 +
(taux_with_orthese[i][30])**2 + (taux_with_orthese[i][31])**2 + (taux_with_orthese[i][32])**2 + (taux_with_orthese[i][33])**2 +(taux_with_orthese[i][34])**2)])),但是不好使啊... 展开
with open('tau_mannequin_1432139027.txt') as f:
for line in f.readlines():
taux_with_orthese.append(map(float,line.replace("\n","").split(",")))
taux_with_orthese = np.array(taux_with_orthese)
tau_norm_instant = []
print tau_norm_instant
for i in range(0,len(taux_with_orthese)-1):
tau_norm_instant = np.array([np.sqrt((taux_with_orthese[i][28])**2 + (taux_with_orthese[i][29])**2 +(taux_with_orthese[i][30])**2 + (taux_with_orthese[i][31])**2 + (taux_with_orthese[i][32])**2 + (taux_with_orthese[i][33])**2+
(taux_with_orthese[i][34])**2)])
print tau_norm_instant
程序这么写完之后 只出现一列数
,我想求这一列数的和 怎么求呢?试过 tau_norm_instant = sum(
np.array([np.sqrt((taux_with_orthese[i][28])**2 + (taux_with_orthese[i][29])**2 +
(taux_with_orthese[i][30])**2 + (taux_with_orthese[i][31])**2 + (taux_with_orthese[i][32])**2 + (taux_with_orthese[i][33])**2 +(taux_with_orthese[i][34])**2)])),但是不好使啊... 展开
1个回答
展开全部
没看懂公式 不过凭经验。。。
tau_norm_instant = np.zero(1)
for i in range(0,len(taux_with_orthese)-1):
tau_norm_instant += np.array([np.sqrt((taux_with_orthese[i][28])**2 + (taux_with_orthese[i][29])**2 +(taux_with_orthese[i][30])**2 + (taux_with_orthese[i][31])**2 + (taux_with_orthese[i][32])**2 + (taux_with_orthese[i][33])**2+
(taux_with_orthese[i][34])**2)])
print tau_norm_instant
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询