这里定义了一个函数,因此它必须是一个标量,但当调用该函数时,我会得到以下错误:形状(3,1)和(3,)未对齐:1(尺寸1)!=3(尺寸0)
def Angle_sun(panel):
print(panel)
sun = np.array([[0], [-1368], [0]])
dott = np.dot(panel, sun)
return math.acos(dott/(np.linalg.norm(panel)) * np.linalg.norm(sun))
其中面板=[[0.],[0.92],[0.39]]
面板为a(3,1)
Tags:
请查看matrix dot product (Wikipedia),对于} ,您将知道为传递给它的不同形状的矩阵生成了什么输出
a.b
,所需矩阵的大小应分别为NxM
和MxN
。如果您查看^{由于上面的
sun
矩阵的维数为3x1
,并且您正在执行panel.sun
,因此panel
矩阵的维数应为1x3
,那么两个形状为1x3
的矩阵的点积为3x1
因此,您拥有的面板列表应该是1D列表,即
[0.0, 0.92, 0.39]
,而不是[[0.0], [0.92], [0.39]]
,这当然是一个2D列表相关问题 更多 >
编程相关推荐