clc; clear all; close all;
u=7;
Nzc=353;
% N=126
for i=1:u
for n=1:Nzc
x(n)=exp(-j*((pi*u*n*(n+1))/Nzc));
end
end
n=1:Nzc;
figure,plot(n,x);
title('Zad off sequence for u=7 and Nzc=353');
xlabel('Time');
ylabel('Amplitude');
x1=abs(x);
figure,plot(n,x1);
x2=xcorr(x);
figure,plot(1:(2*Nzc)-1,x2);
x3=fft(x);
figure,plot(n,x3);
u=1;
for n=1:Nzc
x(n)=exp(-j*((pi*u*n*(n+1))/Nzc));
end
u=2;
for n=1:Nzc
y(n)=exp(-j*((pi*u*n*(n+1))/Nzc));
end
x5=xcorr(x,y);
figure,plot(1:(2*Nzc)-1,x5);
%pss generation
pss_temp = zeros(31,2);
for n=1:31
pss_temp(n,1) = exp(-1i*pi*u*(n-1)*n/63);
pss_temp(n,2) = exp(-1i*pi*u*(n+31)*(n+32)/63);
end
pss = reshape(pss_temp,62,[]);
NID1=0; NID2=1;
qq = floor(NID1/30);
q = floor((NID1+qq*(qq+1)/2)/30);
mm = NID1+q*(q+1)/2;
m0 = mod(mm,31);
m1 = mod(m0+floor(mm/31)+1, 31);
PNgen = commsrc.pn('GenPoly', [1 0 0 1 0 1], ...
'InitialStates', [1 0 0 0 0], ...
'Shift', 0, ...
'NumBitsOut', 31);
PNtemp = generate(PNgen).';
PNseq = 1-2*PNtemp;
SCgen1 = commsrc.pn('GenPoly', [1 0 1 0 0 1], ...
'InitialStates', [1 0 0 0 0], ...
'Shift', 0, ...
'NumBitsOut', 31);
SCtemp = generate(SCgen1).';
SCseq1 = 1-2*SCtemp;
SCgen2 = commsrc.pn('GenPoly', [1 1 0 1 1 1], ...
'InitialStates', [1 0 0 0 0], ...
'Shift', 0, ...
'NumBitsOut', 31);
SCtemp = generate(SCgen2).';
SCseq2 = 1-2*SCtemp;
SSS = zeros(62,1);
for n=0:30
SSS(2*n+1) = PNseq(mod(n+m0,31)+1).*SCseq1(mod(n+NID2, 31)+1);
SSS(2*n+2) = PNseq(mod(n+m1,31)+1).*SCseq1(mod(n+NID2+3,31)+1).*SCseq2(mod(n+mod(m0,8),31)+1);
% case 6
% SSS(2*n+1) = PNseq(mod(n+m1,31)+1).*SCseq1(mod(n+NID2, 31)+1);
% SSS(2*n+2) = PNseq(mod(n+m0,31)+1).*SCseq1(mod(n+NID2+3,31)+1).*SCseq2(mod(n+mod(m1,8),31)+1);
end
% for n=1:Nzc
% x1(n)=x(n+Nzc)
% end
% n=1:Nzc;
% figure,plot(n,x1);
% title('Zad off sequence for u=7 and Nzc=353');
% xlabel('Time');
% ylabel('Amplitude');