📄 maxlen.m
字号:
% Binary Maximal Length Sequence Code
% Program Generates a Random Sequence
% ------------------------------------
clear;clc;
% Code Length and Feedback (m=2-7;9-11)
m=input('length=');
a=m-1;
if m==5;a=3;end;
if m==9;a=5;end;
if m==10;a=7;end;
if m==11;a=9;end;
l=2^m-1;
% Start sequence
x= eye(1,m);
z=x;
% Generate sequence of zero-ones
for j=1:l;
for i=2:m;x(i)=z(i-1);x(1)=z(a)+z(m);end;
if x(1)==2;x(1)=0;end;
y(j)=z(m);z=x;end;
% Convert to sequence of 1,-1
for i=1:l;
if y(i)==0;y(i)=-1;end;
end;
% Plot correlation
t=1:2*l-1;zz=xcorr(y);
plot(t,abs(zz));grid;
xlabel('Time');
ylabel('Voltage Correlation');
title(['Binary Code Autocorrelation']);
% Display Sequence
b=input('Display Sequence Yes=1;No=0; ');
if b==1;disp(y);end;
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -