📄 pr6_47.m
字号:
%Problem 6.47;
%tests binary polynomial on being primitive;
clear all; close all;
fprintf('\n');
n=12; %set degree of polynomial;
N=2^n-1; %m-sequence length;
F=[]; %initialization of primitive polynomial array;
din=[1,zeros(1,n-1)]; %initial LFSR loading;
t=cputime;
for k=0:2^(n-1)-1 %range of k is taken ignoring polynomial being mirror images of the already tested;
f=[1 bitget(k,1:n-1) 1]; d=lseq(f,din); a=-2*d+1; %calculates linear sequence and concverts it to binary {+1,-1} alphabet;
R=xcorr(a); %calculates ACF
if max(R(N+1:2*N-1)+R(1:N-1))<=-0.9; F=[F;f]; end; %test whether we came to m-sequence or other sequence by checking periodic ACF;
end;
disp('table of primitive polynomials');
disp(F);
T=cputime-t;
fprintf('\n');
disp(['computation time T=',num2str(T)]);
fprintf('\n');
beep;
fa=[1,0,1,0,1,1,1]; n=length(fa)-1; din=[1,zeros(1,n-1)]; %feedback polynomial, length and initial state of sequence asked about;
da=lseq(fa,din); %sequence forming;
Nt1=seqperiod(da);
fprintf('\n');
disp(['sequence period L=',num2str(Nt1)]);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -