I have a vector y
of size 4 x 1
, and another vector y2
of size 1 x 4
, I need to concatenate the vectors y
and real and imaginary parts of y2
.
The problem is that when I reshape the vector y2
into vector 4 x 1
, and then concatenate it with vector y
, it gives me an error of 'all the input array dimensions except for the concatenation axis must match exactly'
.
Here is the code I made, So Y3
is expected to be a vector of size 12 x 1
, but the last command gives an error:
import numpy as np
h = np.random.randn(4, 4) + 1j * np.random.randn(4, 4)
x = np.array([[1 + 1j], [0 + 0j], [0 + 0j], [0 + 0j]])
y = h.dot(x)
n = 3
y2 = np.zeros((1, 4), dtype=np.complex)
for ii in range(n):
y2[: , ii] = np.linalg.pinv(h[: , ii].reshape(-1,1)).dot(x)
y_con = np.concatenate((np.real(y2),np.imag(y2)))
y_m = np.absolute(y)
y_con2 = y_con.reshape(8,1)
Y3 = np.concatenate((y_con2, y_m))