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

📄 mseq.m

📁 The source codes are from the "Simulation and software Radio for mobile communication" It contain th
💻 M
字号:
% Program 5-3
% mseq.m
%
% The generation function of M-sequence
%
% An example
%    stg     = 3
%    taps    = [ 1 , 3 ]
%    inidata = [ 1 , 1 , 1 ]
%    n       = 2
%
% Programmed by M.Okita and H.Harada
%

function [mout] = mseq(stg, taps, inidata, n)

% ****************************************************************
% stg     : Number of stages
% taps    : Position of register feedback
% inidata : Initial sequence
% n       : Number of output sequence(It can be omitted)
% mout    : output M sequence
% ****************************************************************

if nargin < 4
    n = 1;
end

mout = zeros(n,2^stg-1);
fpos = zeros(stg,1);

fpos(taps) = 1;

for ii=1:2^stg-1
    
    mout(1,ii) = inidata(stg);                      % storage of the output data
    num        = mod(inidata*fpos,2);               % calculation of the feedback data
    
    inidata(2:stg) = inidata(1:stg-1);              % one shifts the register
    inidata(1)     = num;                           % return feedback data
    
end

if n > 1
    for ii=2:n
        mout(ii,:) = shift(mout(ii-1,:),1,0);
    end
end

%******************************** end of file ********************************

⌨️ 快捷键说明

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