How to generate a set of N mutually orthogonal (N being a power of 2) N-dimensional binary vectors [+1,-1]?

23 Ansichten (letzte 30 Tage)
For instance:
with N=2 we could have [1 1; 1 -1]
with N=4, we could have [1 1 1 1; 1 1 -1 -1; 1 -1 1 -1; 1 -1 -1 1]
How to efficiently generate N mutually orthogonal binary vectors for larger N (8,16,32,64,...,4096,...)?

Akzeptierte Antwort

Matt J
Matt J am 8 Mär. 2021
Bearbeitet: Matt J am 8 Mär. 2021
N=4096;
[C,C0]=deal([1 1;1 -1]);
tic;
for i=1:log2(N/2)
C=kron(C0,C);
end
toc
Elapsed time is 0.079038 seconds.
isOrthogonal=isequal(C*C.', N*speye(N))
isOrthogonal = logical
1
C
C = 4096×4096
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 1 -1 -1 1 1 -1 -1 1 1 -1 -1 1 1 -1 -1 1 1 -1 -1 1 1 -1 -1 1 1 -1 -1 1 1 1 -1 -1 1 1 -1 -1 1 1 -1 -1 1 1 -1 -1 1 1 -1 -1 1 1 -1 -1 1 1 -1 -1 1 1 -1 1 1 1 1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 1 1 1 1 -1 -1 1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 1 1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 1 1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 1 -1 1 -1 1 -1 1 -1 -1 1 -1 1 -1 1 -1 1 1 -1 1 -1 1 -1 1 -1 -1 1 -1 1 -1 1
  3 Kommentare
Mohamed
Mohamed am 30 Apr. 2023
Verschoben: Matt J am 30 Apr. 2023
Each signal must be orthogonal to every other 15 signals in the set. What function do i use since (dot) is for two variables?
Matt J
Matt J am 30 Apr. 2023
This line was used above to verify mutual orthogonality:
isOrthogonal=isequal(C*C.', N*speye(N))

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (2)

Steven Lord
Steven Lord am 8 Mär. 2021
See the hadamard function.
  1 Kommentar
Matt J
Matt J am 8 Mär. 2021
For some reason, I find this a fair bit slower than the kron-based solution
N=4096;
tic;
[C,C0]=deal([1 1;1 -1]);
for i=1:log2(N/2)
C=kron(C0,C);
end
toc
Elapsed time is 0.075004 seconds.
tic; hadamard(N); toc
Elapsed time is 0.305544 seconds.

Melden Sie sich an, um zu kommentieren.


Walter Roberson
Walter Roberson am 31 Jan. 2018
(dec2bin(0:(2^(N-1)-1),N)-'0') * 2 - 1
  9 Kommentare
Shlomo Geva
Shlomo Geva am 8 Mär. 2021
On the machine I use we can go up to 131072 x 131072 x 8 bytes (using 2^9 and 2^8 in code above). It takes 10 seconds. We have 1.5TB of RAM. After that we are toast, but that is all we need so this is great.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by