2016-11-13 151 views
0

我正在研究一个项目,以完成我在大学的最终工作。这是计算无人机手臂厚度的算法。 我做了SageMath表达和在Python“不支持的操作数类型为**或pow():'list'和'int'”

import math 
import matplotlib.pyplot as plt 
import pylab 

F=float((2*9.81)/4) 
S=float(1.5) #coeficiente de segurança 
Tensrup=float(4.1575e+7) #Tensão de ruptura 
T=Tensrup/S #Tensão adm (que foi multiplicada por 1.1) 
r=float(0.75*10**-3) #raio interior 
b=range(1, 1000) 
L=[x*10**-3 for x in b] #*10**⁻3 is a unity conversion 
R=[] 
for l in L: 
    R.append(1/10000*math.sqrt(1/3)*math.sqrt((75000000*(6050000000/98695877281*F**2*L**2*S**2/T**2 + 1/37010953980375000000000*math.sqrt(5147226562500000000000000000000000000000000*F**4*L**4*S**4 + 9740876192266211952961/3*T**4)/T**2)**(2/3) - 1)/(6050000000/98695877281*F**2*L**2*S**2/T**2 + 1/37010953980375000000000*math.sqrt(5147226562500000000000000000000000000000000*F**4*L**4*S**4 + 9740876192266211952961/3*T**4)/T**2)**(1/3)) + 1/2*math.sqrt(3300000000/314159*math.sqrt(1/3)*F*L*S/(T*math.sqrt((75000000*(6050000000/98695877281*F**2*L**2*S**2/T**2 + 1/37010953980375000000000*math.sqrt(5147226562500000000000000000000000000000000*F**4*L**4*S**4 + 9740876192266211952961/3*T**4)/T**2)**(2/3) - 1)/(6050000000/98695877281*F**2*L**2*S**2/T**2 + 1/37010953980375000000000*math.sqrt(5147226562500000000000000000000000000000000*F**4*L**4*S**4 + 9740876192266211952961/3*T**4)/T**2)**(1/3))) - (6050000000/98695877281*F**2*L**2*S**2/T**2 + 1/37010953980375000000000*math.sqrt(5147226562500000000000000000000000000000000*F**4*L**4*S**4 + 9740876192266211952961/3*T**4)/T**2)**(1/3) + 1/75000000/(6050000000/98695877281*F**2*L**2*S**2/T**2 + 1/37010953980375000000000*math.sqrt(5147226562500000000000000000000000000000000*F**4*L**4*S**4 + 9740876192266211952961/3*T**4)/T**2)**(1/3))) 
plot = plt.figure(1) 
plt.plot(L,R) 
plt.ylabel("Raio exterior (m)") 
plt.xlabel("Largura do braço (m)") 
plt.title("Dimensionamento dos braços", fontweight='bold') 
plt.grid(True) 
plt.tight_layout() 

pylab.show() 

我想创造该btween 1和1000(然后我乘以用于10⁻3在毫米到变换)而变化的lenght(L)和avaliate点所开发指出看到手臂的最佳长度。 当我运行它,我收到此错误

The debugged program raised the exception unhandled TypeError 
"unsupported operand type(s) for ** or pow(): 'list' and 'int'" File: 
/home/zanetti/Documents/Python/DRone.py, Line: 14 

我是一个爱好者和初学者的代码。我已经尝试使用列表和数组的东西,但事实是,我不明白几乎没有=/

回答

1

你循环上的L元素l但你在你的大compulation使用L行,而你应该使用l

这意味着在某些时候解释器在L**2绊倒这是一个列表升级到第二强度,这在Python中没有意义。

建议:避免带有相同名称的变量,这些变量只是大小写不同。改进命名变量将为您节省很多麻烦。

+1

+1表示最后一部分。认真。命名是困难的,但任何事情都比单字母的名字更好(除非也许我会编写通用的,功能性的HOF)。具有描述性! – Carcigenicate

+0

谢谢。我在回答“简单”问题时尝试添加一些内容。 –

相关问题