⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pr7_40.m

📁 Spread Spectrum and CDMA Principles and Applications 书籍和代码
💻 M
字号:
%Problem 7.40;
%generating Gold ensemble;

clear all; close all;
n=7; %set m-sequence memory nonmultiple of four greater than four;
L=2^n-1; K=L+2; %length of m-sequence and number of Gold sequences;
d=bmsq(n); %constructing first initial m-sequence;
t=5; if mod(n,2)==1 t=3; end; %decimation index for odd n is 3, for even n is 5;
c=d(mod(t*[0:L-1],L)+1); %second initial m-sequence obtained by decimation;   
G=[zeros(14,L);1-2*d;1-2*c]; %template for 16 Gold sequences;
sh1=unidrnd((L+1)/16,1,16)-1; sh=sh1+[0:15]*((L+1)/16); %forming 16 random cyclic shifts;
for k=1:14
    c=circshift(G(16,:),[0,sh(k)]);
    G(k,:)=G(15,:).*c; %symbolwise product of shifted c by d;
end; %Gold set ready;
R=xcorr(G'); %aperiodic correlations;
R=R'; R=R(:,L:end)+[zeros(256,1),R(:,1:L-1)]; %all periodic correlations;
Ind1=[1:17:256]; Ind2=setdiff([1:256],Ind1); %separation of ACF and CCF places in R;
Ram=max(max(abs(R(Ind1,2:end)))); Rcm=max(max(abs(R(Ind2,:)))); Rm=max(Ram,Rcm); %maximal ACF sidelobe and CCF peak;
fprintf('\n');
disp('   length       K         Ram      Rcm       SqRm    SqRm bound'); 
disp([L,K,Ram,Rcm,(Rm^2)/(L^2),2/L]); %displays length, number of sequences in set, maximal ACF sidelobe, maximal CCF peak, squared correlation peak and its lower bound;
subplot(311); plot([0:L],[R(256,:),R(256,1);R(255,:),R(255,1)]'/L); ylabel('Ra(\tau), Rc(\tau)'); xlim([0,L]); grid; ylim([-1.2*Rm/L,1.2]); legend('ACF','CCF'); %plotting ACF of initial and CCF of two initial m-sequences;
subplot(312); plot([0:L],[R(1,:),R(1,1);R(2,:),R(2,1)]'/L); ylabel('Ra(\tau), Rc(\tau)'); xlim([0,L]); grid; ylim([-1.2*Rm/L,1.2]); legend('ACF','CCF'); %plotting ACF and CCF of non-initial Gold sequences;
xlabel('\tau/\Delta');
R1=[reshape(R(Ind1,2:end),1,16*(L-1)),reshape(R(Ind2,:),1,240*L)]; %linear vector to build the histogram;
hs=hist(R1,[-Rm-2:Rm+2])/length(R1);  %calculation of CF histogram;
subplot(313); bar([-Rm-2:Rm+2]/L,hs); xlim([-Rm-2,Rm+2]/L); ylim([0,1.2*max(hs)]); xlabel('correlation'); ylabel('occurences'); grid; %plotting histogram of correlations;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -