我正在尝试连接,但结果却提到了错误。我也是python的新手。
def cving(x1, x2, x3, x4, x5, y1, y2, y3, y4, y5, ind1, ind2, ind3, ind4, ind5, num):
if num == 0:
xwhole = np.concatenate((x2, x3, x4, x5), axis=0)
yhol = np.concatenate((y2, y3, y4, y5), axis=0)
return x1, y1, ind1, xwhole, yhol
elif num == 1:
xwhole = np.concatenate((x1, x3, x4, x5), axis=0)
yhol = np.concatenate((y1, y3, y4, y5), axis=0)
return x2, y2, ind2, xwhole, yhol
elif num == 2:
xwhole = np.concatenate((x1, x2, x4, x5), axis=0)
yhol = np.concatenate((y1, y2, y4, y5), axis=0)
return x3, y3, ind3, xwhole, yhol
elif num == 3:
xwhole = np.concatenate((x1, x2, x3, x5), axis=0)
yhol = np.concatenate((y1, y2, y3, y5), axis=0)
return x4, y4, ind4, xwhole, yhol
else:
xwhole = np.concatenate((x1, x2, x3, x4), axis=0)
yhol = np.concatenate((y1, y2, y3, y4), axis=0)
return x5, y5, ind5, xwhole, yhol
以下是x1,x2,x3和x4的一些输出*显示用于np.concantate的一些输出
x1 = [[ 1.21537030e+07 5.73132800e+06 1.39127063e-01 ..., 0.00000000e+00
0.00000000e+00 0.00000000e+00]
[ 2.19181650e+07 6.31495600e+06 1.58992826e-01 ..., 0.00000000e+00
0.00000000e+00 0.00000000e+00]
[ 9.35311000e+05 5.93920000e+05 1.40974499e-01 ..., 0.00000000e+00
0.00000000e+00 0.00000000e+00]]
x2= []
x3= []
x4 = [ 1.11088300e+06 1.23238400e+06 1.32048109e-01 1.05878525e-01
9.01409788e-01 1.24716612e+00 7.22766415e-01 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 1.15544472e-01 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
1.54537898e-02 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 7.82815688e-01
1.13352981e-04 1.13352981e-04 0.00000000e+00 0.00000000e+00
8.52792262e-02 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 6.80117887e-04 0.00000000e+00 0.00000000e+00]
答案 0 :(得分:2)
错误消息显示全部:x1
是2D而x4
是1D。连接它们毫无意义。您需要确保所有级联数组具有相同的维度,例如通过向所有1D数组添加维度
x4 = x4[:, np.newaxis]