mseq.m

来自「自适应滤波原理_西蒙.赫金_Matlab_源代码 希望能够对学习自适应滤波技术」· M 代码 · 共 28 行

M
28
字号
function seq = mseq(N)
% usage: seq = mseq(N)
% where: seq = m-sequence of length 2^N -1
%          N = order of the m-sequence (max of 14)
% Generates a (+1,-1) maximal-length PN sequence of order N.
% To include the all 1's state, add an extra 1 at the beginning
% for a sequence of length 2^N. (ie. seq=[1,mseq(N)] )
m = 2^N -1;   % length
seq = [ones(1,N-1), -1];
if (N==2 | N==3 | N==4 | N==6 | N==7)
  for n=N+1:m seq(n)=seq(n-N)*seq(n-1); end; end;
if (N==5 | N==10)
  for n=N+1:m seq(n)=seq(n-N)*seq(n-3); end; end;
if (N==8)
  for n=N+1:m seq(n)=seq(n-N)*seq(n-4)*seq(n-3)*seq(n-2); end; end;
if (N==9)
  for n=N+1:m seq(n)=seq(n-N)*seq(n-5); end; end;
if (N==11)
  for n=N+1:m seq(n)=seq(n-N)*seq(n-2); end; end;
if (N==12)
  for n=N+1:m seq(n)=seq(n-N)*seq(n-7)*seq(n-4)*seq(n-3); end; end;
if (N==13)
  for n=N+1:m seq(n)=seq(n-N)*seq(n-4)*seq(n-3)*seq(n-1); end; end;
if (N==14)
  for n=N+1:m seq(n)=seq(n-N)*seq(n-12)*seq(n-11)*seq(n-1); end; end;
if (N==15)
  for n=N+1:m seq(n)=seq(n-N)*seq(n-10)*seq(n-8)*seq(n-7)*seq(n-6)*seq(n-2); end; end;
    

⌨️ 快捷键说明

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