我有这个MATLAB代码,我需要翻译成python,但是在触发数组中创建一个新列有一个问题。在MATLAB中,代码创建一个最初为空的n*2矩阵,我希望能够在python中这样做。使用NumPy,我创建了fired = np.where(v >= 30)。然而,python创建一个元组而不是数组,因此它抛出一个错误:
TypeError: unsupported operand type(s) for +: 'int' and
我的MATLAB代码:#y_test is 1x178 double arrayplot(x,[padding,y_test])#pythonpadding=np.full((179),np.nan)它显示了这个错误:
ValueError: x and y must have same first dimension, but have shapes (
目前,我想知道numpy数组的行为如何。我觉得从向量(Nx1维度)到“真实数组”(NxN维度),维度并不一致。Detailled版本:因此,我希望shape(b)[0]引用垂直方向(__Nx1数组),就像在2D 数组中。但是维度[0]似乎是数组中的水平方向(__Nx1数组)吗?from numpy import *
b = a[:,0]
print sh