How can we generate an N-dimensional unitary column vector?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I would like to generate an N-dimesnional Unitary Column Vector using MATLAB.
8 Kommentare
Walter Roberson
am 25 Feb. 2019
Xf1 = Xf';
U = Xf1*Xf;
gives 1, so the conjugate transpose of Xf left multiplied by Xf gives a unitary matrix.
If you try for
x = [x1; x2; x3; x4]
A = x * x'
hoping A == eye(4), then
A = [x1 * conj(x1), x1 * conj(x2), x1 * conj(x3), x1 * conj(x4)
x2 * conj(x1), x2 * conj(x2), x2 * conj(x3), x2 * conj(x4)
x3 * conj(x1), x3 * conj(x2), x3 * conj(x3), x3 * conj(x4)
x4 * conj(x1), x4 * conj(x2), x4 * conj(x3), x4 * conj(x4)]
The top left must = 1, so conj(x1) = 1/x1 . Substitute that in,
A = [x1 * 1/x1, x1 * conj(x2), x1 * conj(x3), x1 * conj(x4)
x2 * 1/x1, x2 * conj(x2), x2 * conj(x3), x2 * conj(x4)
x3 * 1/x1, x3 * conj(x2), x3 * conj(x3), x3 * conj(x4)
x4 * 1/x1, x4 * conj(x2), x4 * conj(x3), x4 * conj(x4)]
Now the remaining entries in the first column must be 0, so x2/x1 == 0, x3/x1 == 0, x4/x1 == 0. That can only be true if x1 is infinite (in which case we made an invalid substitution), or if x2, x3, x4 are all 0. So make x2, x3, x4 all 0. But then look in the bottom right corner, x4 * conj(x4). With x4 0, conj(x4) is 0, and x4 * conj(x4) = 0, rather than the 1 required. And if x1 was infinite then x1 * conj(x1) would be infinite rather than 1, so we rule out the x1 infinite case.
Therefore it is not possible to construct a column vector of length 4 such that a right multiplication of it by its complex conjugate gives eye(4).
The left multiplication giving 1 is the best we can do.
John D'Errico
am 25 Feb. 2019
As far as implementing 2-d PCA on your own, that is a BAD idea.
If you have no idea how to use MATLAB sufficiently to be able to do the computations I gave in my answer, then you need to use code written by a professional. So use tools like PCA from the stats toolbox.
Antworten (1)
John D'Errico
am 25 Feb. 2019
Bearbeitet: John D'Errico
am 25 Feb. 2019
Confusing. Usually that means you are also confused about what you really want.
x = rand(4,1) +i*rand(4,1);
x = x/norm(x)
x = x/norm(x)
x =
0.56057676215826 + 0.0425294484210577i
0.292261237849278 + 0.563194470925906i
0.351888409287552 + 0.18104942066974i
0.310227988205874 + 0.168803277611609i
>> x'*x
ans =
1
So x is a vector of length 4, having norm 1, so unitary. It is not a matrix. Are you looking to create a matrix? Must it be complex? Are you looking to create a random matrix? As I said, your question is highly confusing.
format short g
>> x = rand(4,4) +i*rand(4,4);
>> x = orth(x)
x =
-0.10738 - 0.23467i 0.35584 + 0.075661i -0.29957 + 0.017908i 0.074794 - 0.83988i
-0.35853 - 0.54037i -0.38986 + 0.24156i -0.37517 + 0.43408i 0.022772 + 0.19852i
-0.30096 - 0.34939i 0.075507 + 0.40693i 0.23797 - 0.65141i -0.36004 + 0.073921i
-0.26064 - 0.48194i 0.32675 - 0.61583i 0.31589 + 0.0032239i 0.29479 + 0.1646i
So a 4x4 random matrix, such that the columns are orthogonal, unitary, and complex. Actually, the rows also have that same property. So both x'*x and x*x' will both yield an identity matrix.
x'*x
ans =
1 + 0i -1.6653e-16 - 1.1102e-16i -1.3878e-17 + 0i -2.7756e-17 + 9.7145e-17i
-1.6653e-16 + 1.1102e-16i 1 + 0i 1.3878e-16 + 8.3267e-17i 2.047e-16 + 5.5511e-17i
-1.3878e-17 + 0i 1.3878e-16 - 8.3267e-17i 1 + 0i 1.1102e-16 - 2.0817e-17i
-2.7756e-17 - 9.7145e-17i 2.047e-16 - 5.5511e-17i 1.1102e-16 + 2.0817e-17i 1 + 0i
x*x'
ans =
1 + 0i 8.3267e-17 - 2.7756e-17i -1.3878e-17 + 1.1102e-16i 2.7756e-17 - 3.8858e-16i
8.3267e-17 + 2.7756e-17i 1 + 0i 2.6021e-17 - 1.3878e-16i 0 + 3.4694e-16i
-1.3878e-17 - 1.1102e-16i 2.6021e-17 + 1.3878e-16i 1 + 0i 1.5266e-16 - 1.3878e-16i
2.7756e-17 + 3.8858e-16i 0 - 3.4694e-16i 1.5266e-16 + 1.3878e-16i 1 + 0i
Note that the off-diagonal terms are zero to within floating point trash for a double.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Numeric Types finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!