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

19 次查看(过去 30 天)
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,...)?

采纳的回答

Matt J
Matt J 2021-3-8
编辑:Matt J 2021-3-8
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 个评论
Mohamed
Mohamed 2023-4-30
移动:Matt J 2023-4-30
Each signal must be orthogonal to every other 15 signals in the set. What function do i use since (dot) is for two variables?

请先登录,再进行评论。

更多回答(2 个)

Steven Lord
Steven Lord 2021-3-8
See the hadamard function.
  1 个评论
Matt J
Matt J 2021-3-8
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.

请先登录,再进行评论。


Walter Roberson
Walter Roberson 2018-1-31
(dec2bin(0:(2^(N-1)-1),N)-'0') * 2 - 1
  9 个评论
Shlomo Geva
Shlomo Geva 2021-3-8
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by