閱讀308 返回首頁    go 技術社區[雲棲]


matlab產生m序列代碼

%%%產生m序列
function[seq]=mseq(connections,registers,len)%registers為寄存器初值序列,connections為各個寄存器的反饋連接取值序列(0/1)(不包括第一個寄存器)
m=length(connections);
L=2^m-1;%m序列周期長度
if len==0
    len=L;%len需要輸出序列的長度
end
fan=0;
for i=1:len
    seq(i)=registers(m);%seq(i)為輸出(第m個寄存器的值)
    for j=1:m
        fan=fan+connections(j)*registers(j);
        fan=(mod(fan,2));%fan為第一個寄存器移位輸入1或0
    end
    for t=m:-1:2%寄存器移位
        registers(t)=registers(t-1);
    end
    registers(1)=fan;
    fan=0;
end

最後更新:2017-04-03 14:53:45

  上一篇:go 樓層扔雞蛋問題
  下一篇:go linux shell 基礎 使用日誌與心得