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

📄 pr6_46.m

📁 Spread Spectrum and CDMA Principles and Applications 书籍和代码
💻 M
字号:
%Problem 6.46
%properties of m-sequences; uses function bmseq;

clear all; close all;
n=6; %inputting memory (primitive polynomial degree);
N=2^n-1; %length of m-sequence;
d=bmsq(n); %forming m-sequence using function bmsq;
subplot(411); stairs([0:2*N],[d d d(1)]); ylim([-0.2 1.2]); ylabel('d(i)'); xlim([0 2*N]); grid; %plotting m-sequence;
m=12; m=rem(m,N); %shift to check shift-and-add property;
d1=circshift(d',m)'; %shifted copy of m-sequence;
subplot(412); stairs([0:2*N],[d1 d1 d1(1)]); ylim([-0.2 1.2]); ylabel('d(i-m)'); xlim([0 2*N]); grid; %plotting shifted m-sequence;
d2=xor(d,d1); %modulo 2 addition of inituial and shifted replicas;
subplot(413); stairs([0:2*N],[d2 d2 d2(1)]); ylim([-0.2 1.2]); ylabel('d(i)+d(i-m)'); xlim([0 2*N]); xlabel('i'); grid; %plotting sum of copies;
a=-2*d+1; %transferring to +1,-1 sequence;
R=xcorr([a a a],a)/N; R=R(3*N:5*N); %calculating periodic ACF;
subplot(414); plot([0:2*N],R); ylim([-0.1-1/N 1.2]); ylabel('PACF'); xlabel('tau'); xlim([0 2*N]); grid; %plotting m-sequence PACF;

r=[0,0,0]; l=length(r)-1; %input run and find its length but one to extend a period of m-sequence;
de=[d d(1:l)]; %extension of m-sequence to count number of runs;
Nr=0;
for k=1:N
    if r==de(k:k+l) Nr=Nr+1;
    end;
end; %number of runs counted;
fprintf('\n');
r=sprintf('%g',r); %conversts run vector to a string for displaying;
disp(['mem n=',num2str(n)]); 
disp(['length N=',num2str(N)]);
disp(['run r=',r]);
disp(['run length l=',num2str(length(r)+1)]);
disp(['number of runs Nr=',num2str(Nr)]); %last five rows display memory, length, fun, length of run and number of runs;

⌨️ 快捷键说明

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