-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgenComplFromFourierConst.m
43 lines (34 loc) · 1.15 KB
/
genComplFromFourierConst.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
% Following "M-ARY MUTUALLY ORTHOGONAL COMPLEMENTARY GOLD CODES"
% We generate sequences of constant magnitude
% and take their IFFT.
% The real and imaginary parts should be constant.
lenSeq = 5;
freqVect = zeros(lenSeq,1);
for i = 1:lenSeq
% Pick a random real magnitude for this sequence element
realMag = rand();
imMag = sqrt(1-realMag^2);
freqVect(i) = realMag + sqrt(-1)*imMag;
end
% Take the inverse Fourier transform
timeVect = ifft(freqVect);
xcorr(timeVect);
% seq1 = real(timeVect)
% seq2 = imag(timeVect)
% xcorr(seq1,seq1) + xcorr(seq2,seq2)
% dot(seq1,seq2)
% Doesn't seem to work.
% I think there needs to be more restrictions on the codes.
% "generated by applying an IDFT to N +1 bipolar Gold sequences"
goldseq = comm.GoldSequence('FirstPolynomial','x^5+x^2+1',...
'SecondPolynomial','x^5+x^4+x^3+x^2+1',...
'FirstInitialConditions',[0 0 0 0 1],...
'SecondInitialConditions',[0 0 0 0 1],...
'Index',4,'SamplesPerFrame',10);
x = step(goldseq)
timeVect = ifft(x);
seq1 = real(timeVect);
seq2 = imag(timeVect);
xcorr(seq1,seq1) + xcorr(seq2,seq2)
dot(seq1,seq2)
% These seem to be orthogonal but not complementary...