我想做这样的操作:
width = 23
alpha_i = np.array([1.84704762, 1.7878235 , 1.72701305, 1.66501652, 1.60228591,
1.53930674, 1.47657613, 1.41457961, 1.35376915, 1.29454503])
w_s_i = (wc / c) * d * np.cos(alpha_i)
ws_idx = np.zeros((width, 1)) # vettore che contiene "width" elementi spaziati di 1
ii = 0
for i in range(np.int(np.floor(width / 2)),-np.int(np.floor(width / 2))-1,-1):
ws_idx[ii,:] = i
ii = ii + 1
# eq.(7)
steer_vecs = np.zeros((width, alpha_i.shape[0]));
for i in range(0,10):
steer_vecs[:, i] = np.squeeze(np.exp(1j * np.multiply(ws_idx ,w_s_i[i])),axis=1)
但是我不知道为什么在最后一个for循环的末尾虚数部分被丢弃。我得到以下错误:
ComplexWarning: Casting complex values to real discards the imaginary part
有什么建议吗?谢谢!
左边的steer_vecs[:, i]
是默认类型float64
的数组。因此,如果你尝试将复杂的值赋给浮点数组,你会得到警告。
所以你需要声明steer_vecs
为一个复杂数组:
steer_vecs = np.zeros((width, alpha_i.shape[0]), dtype=np.complex)